Hi all,
I need to set a default 'Price List' in the 'Opportunity' screen to bypass the need to save before entering the products. Now I've done some scratching around on the internet and come up with the following code:
// Call this function on Opportunity Form onLoad
function frmOnLoad() {
// If form Type = Create
if (Xrm.Page.ui.getFormType() == 1) {
// 1st Parameter is Price List Name, 2nd Parameter is Price List GUID
SetDefaultPriceList("MSC Product Set", "{BA46FE34-38BE-E211-896A-3C4A92DBDC51}");
}
}
function SetDefaultPriceList(prmPriceListName, prmPriceListId) {
//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 = prmPriceListId;
lookupItem.typename = "pricelevel";
lookupItem.name = prmPriceListName;
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("pricelevelid").setValue(lookupData);
}
Problem is, I'm not sure where to put it and if I need to do anything else, unfortunately none of the sites had any kind of walkthrough for it, just the code.
So thought I would see if there was anyone here that could help me out?
Also need to set 'Primary Unit' as the default unit on the 'Opportunity Product Window', would this be the same process?
Many thanks for all your help, it is greatly appreciated.
Kind regards
Nick