I was fixing some code where the code passes a field to a form and then opens it using the excellent Xrm.Utility.openEntityForm
this.SelectCustomer = function () {
/// <summary>
/// Passes customer field values into the customer search screen for a user to create / search
/// for their workshop entry
/// </summary>
var parameters = {};
parameters[ “paramater_1”] = “name”;
parameters[ “paramater_2”] = “hosk_searchfield”;
Xrm.Utility.openEntityForm( “Hosk_Search”, null, parameters);
};
I wanted to add one more field but when I added a new field, the form didn’t open and I just got an error. A generic, which doesn’t tell you anything, I have been getting quite a few of these errors the last couple of weeks
I tried to debug the javascript onload but it wasn’t even being called.
I took away the new field and it worked.
FRUSTRATTTTING
calm down, be logical, engage brain.
I started with the SDK/documentation, lets see what should happen
- parameters
- Type: Object
Optional: A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error. Valid extra query string parameters are:
- Form id: To set the id value of the main form to use when more than one form is available. The parameter is formid.
- Default field ids: To set default values for a new record form. For more information, see Set field values using parameters passed to a form.
- The navbar and cmdbar parameters described in Query String Parameters for the Main.aspx Page.
- Custom query string parameters: A form can be configured to accept custom query string parameters. For more information, see Configure a form to accept custom querystring parameters.
It turns out the parameters are an optional dictionary object and more importantly
Invalid query parameters will cause an error
So basically when I passed an extra variable but I hadn’t added the variable to the form so it was erroring.
So where do you add these pesky form variables
- go to the form
- Form Properties
- Parameters
So I added in the new parameter, saved and published and boom, everything was working, hazaar.
Who thought CRM would have been so picky, ok hands down everyone
One thought on “CRM 2011 – error using Xrm.Utility.OpenEntityForm”