Answered by:
CRM 2011: Using Xrm.Utility.openEntityForm to pass in both the formid and a parameter... breaks the parameter.

Question
-
When I send in the form id, the logic works fine but parameter_0 stops working. If I do not send in the formid, parameter_0 works. Any idea if I need to adjust my parameter list on the form when I add use the formid to load a given form?
I may have just introduced an error at some point in my code, but from the looks of it, using the formid seems to mess up my parameter's.
Do I need to do something in the form's parameter settings when using the formid like this? I need to pass in both the formid and the guid of a parent entity, as I have multiple forms for the child entity and I need to use JavaScript to control which one is loaded, but I need to the guid of the parent to perform various logic on the newly opened form and access the parent entity.
This is firing via a ribbon button. loanId is the guid of the parent entity that is captured when the button is clicked. Works fine for a single form for the child entity, but doesn't work when using two forms like this. It seems to break the parameter that I am passing in. Do I need to adjust the parameter list on the form to account for the formid?
var parameters = {}; parameters["formid"] = "2E4E9CB6-74D2-4EFA-877F-35D2140D6AAF"; parameters["parameter_0"] = loanId; Xrm.Utility.openEntityForm("new_hbc", null, parameters);
Any thoughts or suggestions are much appreciated.
Best regards,
Jon Gregory Rothlander
- Edited by jonrothlander Wednesday, March 4, 2015 3:48 PM
Wednesday, March 4, 2015 3:48 PM
Answers
-
Try to use following - https://msdn.microsoft.com/en-us/library/gg334511.aspx?f=255&MSPPError=-2147217396#BKMK_getquerystringparameter
Dynamics CRM MVP
My blog- Marked as answer by jonrothlander Wednesday, March 4, 2015 5:07 PM
Wednesday, March 4, 2015 5:02 PMModerator
All replies
-
Hello,
Doublecheck that parameter_0 is allowed for form with mentioned identifier. Seems that it is not.
Dynamics CRM MVP
My blogWednesday, March 4, 2015 3:53 PMModerator -
Do you mean in regards to the type? I have it set to unique identifier. Is that the correct open to pass a guid? If I recall correctly, that is what worked in the past, but I might be wrong here.
Jon Gregory Rothlander
Wednesday, March 4, 2015 4:20 PM -
I mean a little bit other thing:
1. Seems that you've added mentioned parameter_0 parameter to a form.
2. Seems that you have 2 (or even more forms) because you are trying to open a form based on formid.
My assumption is following:
1. You've added parameter_0 to form (let's call it 1) which has an id different then "2E4E9CB6-74D2-4EFA-877F-35D2140D6AAF".
2. You haven't added parameter_0 to form that has id "2E4E9CB6-74D2-4EFA-877F-35D2140D6AAF" (form 2).
When you are trying to open form2 form with parameter_0 custom parameter opening fails. That's why I wrote in previous reply:
Doublecheck that parameter_0 is allowed for form with mentioned identifier. Seems that it is not.
Dynamics CRM MVP
My blogWednesday, March 4, 2015 4:27 PMModerator -
Thanks. I am following you now. I did confirm both forms are setup to allow the parameter. However, I think I just realized what I am doing wrong.
How do you pull in the parameter's into your JavaScript? I was passing it in through a form_load event as a parameter list Form_Load(parameter_0). But it seems that they are query strings, not parameter list. So I have to pull it from a the query strings. I guess previously I had it pulling from the query strings and but here I tried to pull it form the form_load function as a parameter.
Jon Gregory Rothlander
- Edited by jonrothlander Wednesday, March 4, 2015 4:56 PM
Wednesday, March 4, 2015 4:48 PM -
Try to use following - https://msdn.microsoft.com/en-us/library/gg334511.aspx?f=255&MSPPError=-2147217396#BKMK_getquerystringparameter
Dynamics CRM MVP
My blog- Marked as answer by jonrothlander Wednesday, March 4, 2015 5:07 PM
Wednesday, March 4, 2015 5:02 PMModerator -
Nice! Hadn't seen that yet. Thanks for the suggestion.
It's working by pulling it from the query string.
Jon Gregory Rothlander
Wednesday, March 4, 2015 5:08 PM