web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Xrm.Utility.openEntityForm - populate lookup in opened form

(0) ShareShare
ReportReport
Posted on by 515

I'm  working with 8,2 on this issue using javascript

I'm having a problem where I cannot open a form using Xrm.Utility.openEntityForm and populate a lookup within that form.

the field name for the lookup in the target form is  lee_fieldnameid

The lookup field relates to the entity that the form is opened from

the code I'm using to try and open this is

var parameters = {};
parameters["lee_fieldnameid"] = varId;
parameters["lee_fieldnameidname"] = varRecordName;
parameters["lee_fieldnameidtype"] = varEntityName;
Xrm.Utility.openEntityForm("lee_targetForm", null, parameters , { openInNewWindow: true });

varId is the id of the current record

varRecordName is the name of the current record

varEntityName is the name of the entity for the current record

I suspect that using id in the fieldname is adding to my confusion, but could someone please point me in the right direction?

Thanks
Lee

I have the same question (0)
  • Lee-Martin Profile Picture
    515 on at

    Looks like I had a syntax error with the information I was passing

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to remove lee_fieldnameidtype part because:

    For simple lookups you must set the value and the text to display in the lookup. Use the suffix “name” with the name of the attribute to set the value for the text.

    Don’t use any other arguments.

    It's written here - docs.microsoft.com/.../gg334375(v=crm.8)

  • Dynamics365Community Profile Picture
    20 on at

    Hi,

    For typical lookups you should avoid declaring type. Therefore, the parameters["lee_fieldnameidtype"] = varEntityName line should be commented in your code.

    Also, if you are struggling with a custom lookup field that has multi-types (for example it has customer type which can take both contact/account types), you should define it as follows:

    //custom lookup field name = "new_customer"

    parameters["new_customer"] = customerId;
    parameters["new_customername"] = customerName;
    parameters["new_customeridtype"] = "contact";

    Pay specific attention to sections green marked!!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans