locked
OnChange set Currency (jscript) RRS feed

  • Question

  • Hi

    I have trouble with change currency with Java Script. I'm using the following code:

    function ChangeCurrencyValue()
    	{
    var currencyid = "B52275BE-28F4-E211-9160-984BE1734553";
    var currencyName = "USD";
    var entityName = "transactioncurrency";
    var myOptionSet = Xrm.Page.getAttribute("col_pipelinetype");
    
    if (myOptionSet.getText() == "SonicWall")
    {
    	Xrm.Page.getAttribute("transactioncurrencyid").setValue([{ name: currencyName, entityType: entityName}]);
    } else {
    ;
    }
    }

    Originally I have EUR, but If I hit the trigger ("optionset - SonicWall") then script changes the value on Currency field -> "USD". If I want to click on this USD value then there doesn't have any predefined actual value (it's empty). How can I tell that script should use the prefefined USD currency value?

    I think it's related with this currencyid = "B52275BE-28F4-E211-9160-984BE1734553". I got it form some webpage. I think I just need to use correct currencyid, but from where do I get it?

    Thanks in Advance!

    Best Regards,

    Andres

    Monday, February 10, 2014 5:02 PM

Answers

  • Settings -> Business Management -> Currencies

    Open the Currency

    In the URL of the window you should see something like this:

    http://yourserver/biz/transactioncurrencies/edit.aspx?id=%7bF149BD7E-EE57-E311-96DF-00155D662A0E%7d

    You need the bold value.

    Also make sure you are setting the ID as well not just the name and type.

    var value = new Array();
    value[0] = new Object();
    value[0].id = "B2D9FA9A-D3F1-472B-89E6-BB2D52117BB3";
    value[0].name = "USD";
    value[0].entityType = "transactioncurrency";
    Xrm.Page.getAttribute("transactioncurrencyid").setValue(value);


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn


    Monday, February 10, 2014 5:05 PM
    Moderator