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 CRM (Archived)

Xrm.Utility.openEntityForm passing lookup parameters not working

(0) ShareShare
ReportReport
Posted on by 50,091 Moderator

Hello Guys,

Unable to pass lookup parameter using openEntityForm . When I passed text field it is redirecting the entity and show me the value, but passing lookup parameter getting generic error .

I checked the lookup id , name value and also all field name are correct.

I followed below link and every blogs are written same , but could not help ,I am redirecting generic error.

https://msdn.microsoft.com/en-us/library/gg334375.aspx?f=255&MSPPError=-2147217396

var parameters = {};
parameters["poc_testlookupfield"] = "2888888E-94D6-E111-9B1D-00155D9D700B";
parameters["poc_testlookupfieldname"] = "Goutam Das";
parameters["poc_testlookupfieldtype"] = "contact";

parameters["poc_testtextfield"] = "test text";

// Open the window.
Xrm.Utility.openEntityForm("poc_testentity", null, parameters);

Any help will be appreciated.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    I got the resolution for this issue- 

    I removed below line and its working for me , not sure why everywhere written we need to pass entity type even MSDN as well , seems its not correct sometimes.

    parameters["poc_testlookupfieldtype"] = "contact";

    Here is the final code which is working for me .

    var parameters = {};
    parameters["poc_testlookupfield"] = "2888888E-94D6-E111-9B1D-00155D9D700B";
    parameters["poc_testlookupfieldname"] = "Goutam Das";
    //No need to pass entity type here parameters["poc_testtextfield"] = "test text"; // Open the window. Xrm.Utility.openEntityForm("poc_testentity", null, parameters);


    Hope this will helps others , I am verifying this as an answer.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Goutam,

    You need the type if the lookup is of multi entity type such as customer.

    Hope this helps.

  • gdas Profile Picture
    50,091 Moderator on at

    Yes Ravi you are correct  , but I  have not seen anywhere written that we don't need to pass entity type for custom lookup which is not multi entity, everywhere written the same and need to pass  entity type.

    Even why you think  passing entity type will give error ? Is there any documentation for that ?

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Gautam,

    Please refer the below link-
    msdn.microsoft.com/.../gg334375.aspx

    Extract here-
    ================
        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.
        For customer and owner lookups you must set the value and the name in the same way you set them for simple lookups. In addition you must use the suffix “type” to specify the type of entity. Allowable values are account, contact, systemuser, and team.
        You can’t set the values for partylist or regarding lookups.
    ======================

    Hope this helps.

  • Teo6666 Profile Picture
    15 on at

    Hi!

    In our case, we have a customer lookup field on Entity called "A" and we would like to open entity from for entity "B"!

    We have code like this (same as on this link: https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334375(v=crm.8)#BKMK_setValueLookupfields):

    var new_contractor = Xrm.Page.getAttribute("new_contractor");

    if (new_contractor){
       parameters["custom_customer"] = contractorId;
       parameters["custom_customername"] = contractorName;
       parameters["custom_customertype"] = "account";
    }


    Customer lookup field called "custom_customer" on entity "B" so we have to pass this parameter, name and type.

    The result when we run this code is an error. It's say:

    Unhandled exception: 
    Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]
    Message: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: CRM Parameter Filter - Invalid parameter 'custom_customertype=account' in Request.QueryString on page /form/Data.aspx.

    Any idea to solve this?

    Regards,

    Teo

  • Community Member Profile Picture
    on at

    I am having the same issue for opening an opportunity record where I am trying to populate the custom customer field from the previously opened opportunity record.

    ALso experiencing that custom_customertype is an Invalid Parameter.

    Were you able to solve this?

  • rgomezj Profile Picture
    60 on at

    Hi, 

    I got this solved by setting the type as following

       parameters["custom_customer"] = contractorId;
       parameters["custom_customername"] = contractorName;
       parameters["custom_customeridtype"] = "account";

    notice the type has "id" in between "customer" and "type" words. Got the idea from the documentation https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334375(v=crm.8)#BKMK_setValueLookupfields
    In that example the URL
    /main.aspx?etn=lead&pagetype=entityrecord&extraqs=ownerid%3D%7bB8C6E040-656E-DF11-B414-00155DB1891A%7d%26owneridname%3DMark%20Folkerts%26owneridtype%3Dsystemuser

    has the type defined as owneridtype

    Regards,




  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you rgomeZj, this worked for me.I was trying to assign customer type code (1 for contact and 2 for account), assigning entityname as you mentioned fixed the issue.Thanks.

  • Suggested answer
    peter qian Profile Picture
    5 on at

    let parameters1 = {

    lookupfield:entityid,

    lookupfieldname:new_name,

    testfield:"abc"

    };

    let parameters2 = {

    lookupfield:{

    id:entityid,

    name:name,

    entityType:entityType

    }

    };

    Xrm.Utility.openEntityForm and Xrm.Navigation.openForm all support parameters1

    Xrm.Utility.openEntityForm not support parameters2

    Xrm.Navigation.openForm support parameters1 and parameters2

    Transition from deprecated client API table of version 9.0 of Dynamics CRM/365

    link:itsfascinating.com/.../

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans