Change currency symbol using JS script without refreshing CRM form

Change currency symbol using JS script without refreshing CRM form

Recently I having a requirement in which I need to change a transaction currency at CRM form using JS. I was able to change the currency but currency symbol is not reflected for all currency attribute on form, for changing we need to refresh explicit the form.

Here is the previous code

var lookupReference = [];
lookupReference[0] = {};
lookupReference[0].id = ‘{TransactionCurrencyId}’;
lookupReference[0].entityType = “transactioncurrency”;
lookupReference[0].name = ‘{CurrencyName}’;
Xrm.Page.getAttribute(“transactioncurrencyid”).setValue(lookupReference);
Xrm.Page.data.save();
Xrm.Utility.openEntityForm(“contact”, Xrm.Page.data.entity.getId());

so after spending some time I came with a way , that we use for change currency symbol on CRM form without refreshing the CRM form.

This is an unsupported way so please careful before using this.

Here is the updated code

var obj= {
id: ‘{TransactionCurrencyId}’,
entityType: ‘transactioncurrency’,
type: 9105,
name: ‘{CurrencyName}’,
keyValues: {
currencysymbol: { name: ‘currencysymbol’, value: ‘{CurrencySymbol}’ },
currencyprecision: { name: ‘currencyprecision’, value: “1” }
}
};
Xrm.Page.getControl(‘transactioncurrencyid’).get_editControlBehavior().handleAfterLookup({ items: [obj] });

 

 

CurrencyChange1

Note : All the curly variable needs dynamic value

e.g.{TransactionCurrencyId}=90300F9F-5560-E611-80EA-005056A93B8D

 

Thanks for visiting my blog.

 

 

 

Leave a comment