Skip to main content

Notifications

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

  • Dynamics365Community Profile Picture
    20 on at
    RE: Xrm.Utility.openEntityForm - populate lookup in opened form

    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!!!

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Xrm.Utility.openEntityForm - populate lookup in opened form

    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)

  • Lee-Martin Profile Picture
    515 on at
    RE: Xrm.Utility.openEntityForm - populate lookup in opened form

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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 181 Super User 2025 Season 1

#2
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 124 Super User 2025 Season 1

Product updates

Dynamics 365 release plans