Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

HCLTech Microsoft Business Applications Practice Blog

for Dynamics 365, Power Platform and the rest of the Microsoft technology stack


Populate a CRM 2011 Lookup or PartyList Field Using JavaScript

Post Author: HCLTech |

There are many benefits to using JavaScript with Microsoft Dynamics CRM 2011, including achieving on screen automation. In today's blog, we'll discuss how to use JavaScript on the field type of Lookup and PartyList.

In the example below, the Sender on the phone call is a Lookup field. To populate a Lookup field with JavaScript, you would use the code below:

   lookUpObject.id = ;
   lookUpObject.name = "Joe CRM";
   lookUpObject.entityType = 2;                
   Xrm.Page.getAttribute("").setValue(lookUpObject);

You'll also see in the example below that the Recipient on the phone call is a PartyList field. This is the JavaScript you would use to populate a PartyList field:

   var partlistData = new Array();
   partlistData[0] = new Object();
   partlistData[0].id = ;
   partlistData[0].name = "Joe CRM";
   partlistData[0].entityType = 2;
   Xrm.Page.getAttribute("to").setValue(partlistData);

The PartyList field in CRM 2011

The PartyList field is used in multiple places in addition to the Phone Call. For example, the To field on an Email, or the Required field on the Appointment.

For more resources on this topic, check out our blog on Reporting on Activities in Microsoft Dynamics CRM, which describes the different PartyList fields and how they are used.

Happy CRM'ing!


Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

6 comments on “Populate a CRM 2011 Lookup or PartyList Field Using JavaScript”

  1. Hello, I do it the way you showed but I get: Attribute 'partyobjecttypecode' cannot be NULL when I try to save, could yo please advise? thank you

  2. Hey Joe! Any idea on how to change the sender address from an email to default to the queue the original mail was sent to, i.e. automatically/dynamically ?
    in crm 2013 i'd guess it would be through the parentactivityid, but dunno how to do use it.
    thanks

  3. When setting a PartyList, how do you add additional records? I'm guessing it's just a matter of repeating the middle 4 lines of code with partlistData[1], partlistData[2], etc. ?

  4. Tried to alter a "from" field on an Email, finally figured it works like a party list:
    var lookUpObject = new Array();
    lookUpObject[0] = new Object();
    lookUpObject[0].id = ai_queue_ai_servicecenter.Id;
    lookUpObject[0].name = ai_queue_ai_servicecenter.Name;
    lookUpObject[0].entityType = "queue";

    Xrm.Page.getAttribute("from").setValue(lookUpObject);

PowerObjects Recommends