Hello community,
This is my first post. I've been using CRM 2011 for two weeks, and the solutions to many of my problems have been found by searching this forum, so thank you.
I have a custom field for Quote, called "Quote For" (id - new_QuoteForEntity) that comes from an option set with (currently) two possibilities. I'd like that if a user creates an opportunity from an account or a contact that it automatically sets this field. I have some code written in jScript below, set to occur onFormLoad, but it fails when the form loads, and I'm not sure why (likely cause I've never written in java before yesterday). Your help would be much appreciated.
function setQuoteFor(){
var lookupItem = new Array();
lookupItem = XRM.Page.getAttribute("customerid").getValue();
if(lookup != null){
var output = newArray();
output[0] = new Object();
if (lookup[0].entityType == "contact"){
output[0].Value = 100,000,000;
output[0].Label = "Contact";
}
if (lookup[0].entityType == "account"){
output[0].Value = 100,000,001;
output[0].Label = "Account";
}
Xrm.Page.getAttribute("new_QuoteForEntity").setValue(output);
}
}