There is another way, unsupported though, which uses the items array that is exposed by the lookup. Here is the complete code example:
function OnCrmPageLoad() {
crmForm.all.parentaccountid.attachEvent("onchange",OnParentAccountChange);
}
function OnPatentAccountChange() {
var parentAccount = crmForm.all.parentaccountid;
if( parentAccount.DataValue != null )
{
var lookupColumns = parentAccount.items[0].keyValues;
alert( lookupColumns.accountnumber.value);
//alert( lookupColumns.<Attribute Schema Name>.value);
}
}
OnCrmPageLoad();
The lookupColumns expose the entire column set you see on the lookup dialog by name.
2 comments:
Hello Adi,
Thanks for the trick... I have tested and it is working on the on change event. I would like to use it also on the onload event.
I am in fact copying the acct number to a field, so when I am loading the page I need to reload my account number (if it has changed). Is it possible?
Hi moonjo,
This only a “trick” as you put it and will work only if you open the lookup dialog.
You should refer to the http://mscrm4ever.blogspot.com/2008/09/ajax-using-fetch-message.html post to get the account number on the “onload” event.
Post a Comment