- Open CRM and go to Settings, Business Management, Currencies
- Open the currency record and select F11 or Cntrl N to view the IE address field if you don’t already have it displayed
- Find the ID contained between the two brackets {}, copy the full value with bracktes and save it for use in the script
Next we’ll open the entity that we want to set with a default currency value.
- Go to Settings, Customization, Customize Entities and open the entity that you want to set the default currency
- Select Forms and Views from the left navigation menu
- Select Form properties from the right "Common Tasks" menu
- Select OnLoad and select Edit
- Copy and paste the script below into the ‘script area’ and check the Event Enabled selection
- Be sure to copy your Currency Guid into the appropriate place in the script
- Select the Dependencies Tab and move the Currency field to ‘Dependent Fields" list
- This will ensure that the field remains on the form
- Save, close and test your changes
You can publish your changes when you are satisfied with the result. I obtained the code below from a CRM post responded to by uMar Khan. Thanks uMar, for the assist!
if (crmForm.FormType == 1)
{
//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = ‘{CopyYourCurrencyGuidHere}’;
lookupItem.typename = ‘transactioncurrency’;
lookupItem.name = ‘US Dollar’;
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
crmForm.all.transactioncurrencyid.DataValue = lookupData;
}
below script i have used in CRM 2011
function setdefaultcurrency()
{
var value = new Array();
value[0] = new Object();
value[0].id = “2ADA7F39-A910-E311-A612-00155D00EE04”
value[0].name = “Svenska kronor”;
value[0].entityType =”transactioncurrency”;
Xrm.Page.getAttribute(“new_currency”).setValue(value);
}
i have use the below script in CRM 2011
function setdefaultcurrency()
{
var value = new Array();
value[0] = new Object();
value[0].id = “2ADA7F39-A910-E311-A612-00155D00EE04”
value[0].name = “Svenska kronor”;
value[0].entityType =”transactioncurrency”;
Xrm.Page.getAttribute(“new_currency”).setValue(value);
}