apollo7
asked on
CRM 2011 Setting Lookup Defaults
I have been able to set a default lookup value (FreightName) using the code below but when I try to set a second lookup (ShipName) , it wipes out my first lookup value and I end up with a value in ShipName but nothing in FreightName. I have tried renaming the lookup elements but this gives me an error.
Please take a look at the code below and let me know what I can do to populate both lookups (actually I have third I need to populate as well)
Thanks
Please take a look at the code below and let me know what I can do to populate both lookups (actually I have third I need to populate as well)
Thanks
function populate(){
var proceedType = Xrm.Page.data.entity.attributes.get("csc_proceedwithquote");
proceedType.setValue(1);
Xrm.Page.getAttribute("csc_proceedwithquote").setSubmitMode("always");
alert("proceedType");
var proceedStatus = Xrm.Page.data.entity.attributes.get("csc_proceedwithquotestatus");
proceedStatus.setValue(862430002);
Xrm.Page.getAttribute("csc_proceedwithquote").setSubmitMode("always");
alert("proceedStatusstatus");
alert("Ribbon Editor Sln");
FreightName();
ShipName();
}
function FreightName() {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "16F711C2-5C9C-E411-8DC3-005056897092"; // Guid Of That Look Up
lookupValue[0].name = "Collect"; // Name Of That Look Up
lookupValue[0].entityType = "Freight Term"; // Entity Name Of That Look Up
Xrm.Page.getAttribute("csc_freightterm").setValue(lookupValue);
}
function ShipName() {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "1EF711C2-5C9C-E411-8DC3-005056897092"; // Guid Of That Look Up
lookupValue[0].name = "Standard Priority"; // Name Of That Look Up
lookupValue[0].entityType = "Shipment Priority"; // Entity Name Of That Look Up
Xrm.Page.getAttribute("csc_shipmentpriority").setValue(lookupValue);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes. correct.
ASKER
When I changed to the code, it leaves both field empty. The code changes below. I may be putting the wrong value, e.g. csc_freightterm is the field name on the form.
function populate():
FreightName();
ShipName();
}
function FreightName() {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "16F711C2-5C9C-E411-8DC3-005056897092"; // Guid Of That Look Up
lookupValue[0].name = "Collect"; // Name Of That Look Up
[b] lookupValue[0].entityType = "csc_freightterm"; // Entity Name Of That Look Up
[/b]
Xrm.Page.getAttribute("csc_freightterm").setValue(lookupValue);
}
function ShipName() {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "1EF711C2-5C9C-E411-8DC3-005056897092"; // Guid Of That Look Up
lookupValue[0].name = "Standard Priority"; // Name Of That Look Up
[b]lookupValue[0].entityType = "csc_shipmentpriority"; // Entity Name Of That Look Up
[/b]
Xrm.Page.getAttribute("csc_shipmentpriority").setValue(lookupValue);
}
ASKER
Ok, got the naming correct to populate the field but have a weird problem as far as what is written to the the fields. After the fields are populated, they look like the following and the form cant be saved.
If I use the spyglass to populate the lookups, then they look correct and the form can be saved.
If I use the spyglass to populate the lookups, then they look correct and the form can be saved.
ASKER
Thanks I have code setup correctly
ASKER
Instead of:
lookupValue[0].entityType = "Freight Term"; // Entity Name Of That Look Up
Use:
lookupValue[0].entityType = "csc_freightterm"; // Entity Name Of That Look Up
Does this look correct?
Thanks