Skip to main content

Notifications

Dynamics 365 general forum

Dynamics 365 - Set Currency field value through JavaScript

Posted on by 125

Hi,

I have to use Javascript to set dynamically the value of the currency field, but I cannot achieve it.

Generally I was trying to achieve it by below solutions:

1) Xrm.Page.data.entity.attributes.get(“currencyfield”).setValue(1000);

2)var field = executionContext.getFormContext().getAttribute("currencyfield");

field.setValue(145000034);


3)

var lookup = new Array();

lookup.type = "Microsoft.Crm.Sdk.Data.Service.Money";

lookup.value = 1000;

Xrm.Page.getAttribute("currencyfield").setValue(lookup);

Unfortunately any of these above solutions doesn't set the value of Field with type "Currency".

Do you have any idea what I'm doing wrong or what should I do set dynamically Currency field?

  • Ali Deldari Profile Picture
    Ali Deldari 20 on at
    RE: Dynamics 365 - Set Currency field value through JavaScript

    the "Currency Name" that you defined in currencies  (Settings > Business Management > Currencies)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamics 365 - Set Currency field value through JavaScript

    What name are we supposed to put for "put here your currency name" ?

  • Suggested answer
    Ali Deldari Profile Picture
    Ali Deldari 20 on at
    RE: Dynamics 365 - Set Currency field value through JavaScript

    Hi

    I had same problem and i searched too many sites and i've tried all solutions

    but finally by debbuging i find this solution:

    befor set field value, write this line of code:

    (Xrm.Page.getAttribute("your field name")).$2_2.$CK_1.Data_23 = "put here your currency name";

    then set value:

    Xrm.Page.getAttribute("your field name").setValue(1000);
  • CSD365 Profile Picture
    CSD365 125 on at
    RE: Dynamics 365 - Set Currency field value through JavaScript

    Look at the first solution, which I have tried:

    It's the same what you've mentioned.

    I have placed this function on change another field, and the function looks like this:

    function SetDiscountValue()
    {
                     Xrm.Page.data.entity.attributes.get(“manualdiscountamount”).setValue(1000);
    }

    When I change the value of one field, it invokes this function, but it returns:

  • Suggested answer
    MNarmeen Profile Picture
    MNarmeen 1,846 on at
    RE: Dynamics 365 - Set Currency field value through JavaScript

    Xrm.Page.data.entity.attributes.get(“Currency field name”).setValue(1000);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans