0
votes

I'm starting to write a simple javascript on CRM Contact page to retrieve the parent account ID.

I set the script as an onChange event on the parent account field (parentcustomerid) and set it to "pass execution context as parameter".

This is my code:

function PopulateAccountType(ParentAccount) {

if (ParentAccount != null) {
    var Account = new Array();
    var Account = Xrm.Page.getAttribute("parentcustomerid").getValue();
    {
        var AccountId = Account[0].id;
    }
  }
}

Not sure why I keep getting error on the OnChange event Object doesn't support property or method 'getValue'.

I've been using 'getValue' function successfully but is it different when the value is an ID?

Thanks for your help, greatly appreciate.

-elisabeth

1

1 Answers

0
votes

Try this Code and Uncheck Execution Parameter Check Box.

function PopulateAccountType() 
{
   var lookup = Xrm.Page.getAttribute("parentcustomerid").getValue();
   if(looup!=null)
   {
    var Account = lookup[0].id;
    alert(Account);
   }