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
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
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.
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,
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?
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
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.
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 ?
Hi Goutam,
You need the type if the lookup is of multi entity type such as customer.
Hope this helps.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156