SP へFieldCurrency オブジェクト (sp.js)

フィールドに関連付けられている拡張プロパティを初期化します。

**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.FieldCurrency()

メンバー

FieldCurrencyオブジェクトでは、次のメンバーがあります。

Constructor

FieldCurrencyオブジェクトでは、次のコンスがあります。

コンストラクター

説明

FieldCurrency

Initializes a new instance of the SP.FieldCurrency object.

プロパティ

FieldCurrencyオブジェクトでは、次のプロパティがあります。

プロパティ

説明

currencyLocaleId

Gets or sets a value that specifies the language code identifier (LCID) used to format the value of the field.

次の例では、現在のサイトのタスク リストに通貨型フィールドを追加するアプリケーション ページの [入力] ボタンを作成します。

<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>

関連項目

その他の技術情報

FieldCurrency リソース