This documentation is archived and is not being maintained.
SP.FieldCurrency object
SharePoint 2013
Specifies a field that contains currency values.
Last modified: March 09, 2015
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.FieldCurrency()
The FieldCurrency object has the following members.
Constructor
The FieldCurrency object has the following constructor.
|
Constructor |
Description |
|---|---|
|
Initializes a new instance of the SP.FieldCurrency object. |
Properties
The FieldCurrency object has the following properties.
|
Property |
Description |
|---|---|
|
Gets or sets a value that specifies the language code identifier (LCID) used to format the value of the field. |
The following example creates an input button on an application page that adds a currency field to the Tasks list of the current site.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/ecmascript" language="ecmascript"> var list; var newfield; function runCode() { var clientContext = new SP.ClientContext.get_current(); if (clientContext != undefined && clientContext != null) { var web = clientContext.get_web(); this.list = web.get_lists().getByTitle("Tasks"); this.newfield = this.list.get_fields().addFieldAsXml('<Field DisplayName=\'Currency\' Type=\'Currency\' />', true, SP.AddFieldOptions.defaultValue); this.newfield = clientContext.castTo(newfield, SP.FieldCurrency); this.newfield.set_currencyLocaleId(1033); this.newfield.update(); clientContext.load(this.newfield); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } } function onQuerySucceeded() { if (this.newfield.get_fieldTypeKind() == SP.FieldType.currency) { alert('Currency field added to Tasks list.'); } else { alert('Error on adding'); } } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } </script> <input id="Button1" type="button" value="Run Code" onclick="runCode()" /> </asp:Content>
Show: