Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Xrm.Utility.openEntityForm passing lookup parameters not working

Posted on by 50,085

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

  • Suggested answer
    peter qian Profile Picture
    peter qian 5 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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/.../

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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.

  • rgomezj Profile Picture
    rgomezj 60 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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,




  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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?

  • Teo6666 Profile Picture
    Teo6666 15 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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.

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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 ?

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    Hi Goutam,

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

    Hope this helps.

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.Utility.openEntityForm passing lookup parameters not working

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans