locked
Trying to set a lookup field, how can I do it? RRS feed

  • Question

  • I'm trying to set a Task lookup field using the following:

                        Xrm.Page.getAttribute("new_taskrecord").setValue([{
                        id: TaccountID,
                        name: TaccountName,
                        entityType: TaccountLD
                    }]);

    Problem is, I'm not sure what values to fill the above with? What exactly do I need to set the lookup field that resolves to a Task record?

    Thursday, July 18, 2013 11:56 AM

All replies


  • var value = new Array();
    value[0] = new Object();
    value[0].id = "B2D9FA9A-D3F1-472B-89E6-BB2D52117BB3";
    value[0].name = "Primary Unit";
    value[0].entityType = "uom";
    Xrm.Page.getAttribute("new_lookup").setValue(value);

    id = the GUID or uniqueidentifier of the record

    name = the text you would see in the lookup after selecting

    entityType = the "Name" field from the entity overview screen unser customizations


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Thursday, July 18, 2013 12:04 PM
    Moderator
  • Jason, thanks for the reply, I'm aware how to do that but what I am trying to do is set a Task Activity in a lookup field.

    Essentially, I have a lookup which looks up "Tasks" (which is an activity entity). I'm trying to set the record using REST. I get the correct record, but I'm not sure what values to use to set the lookup in the TaskSet (https://yourorganisation.crm4.dynamics.com/XRMServices/2011/OrganizationData.svc/TaskSet/).

    I came accross this problem once before but not sure how I fixed it.

    Thursday, July 18, 2013 12:14 PM