Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

JS Code to set account owner name in Sales person 1 field in quote: Is it right

$
0
0

Hi All

I just wrote a javascript code to set the field of sales person1 in quote as the owner of the account.

Please can anyone check and let me know what i am doing wrong. as its giving me undefined in Salesperson1 field.

Thanks

 function SetSalesPerson1(resultXml, userid) {

      var owner= Xrm.Page.getAttribute("ownerid").getValue();
var ownerID = owner[0].id;
var ownerName = owner[0].name;
var entityType = owner[0].account;

       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 = owner.ownerID ;
       lookupItem.entityType ='account';
        lookupItem.name = owner.ownerName ;

        // 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("salesperson1id").setValue(lookupData);

    }


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>