Xrm.Navigation.openForm not honouring formid

血红的双手。 提交于 2019-12-11 02:21:27

问题


I'm trying to follow the examples found here that explain how to use Xrm.Navigation.openForm method to open a CRM form for a new entity.

My target entity has multiple forms and I'm trying to specify the form ID in the entityFormOptions object as described in the link above. I've copied the relevant text here (with the relevant line in bold):

entityFormOptions

Entity form options for opening the form. The object contains the following attributes:

  • cmdbar: (Optional) Boolean. Indicates whether to display the command bar. If you do not specify this parameter, the command bar is displayed by default.
  • createFromEntity: (Optional) Lookup. Designates a record that will provide default values based on mapped attribute values. The lookup object has the following String properties: entityType, id, and name (optional).
  • entityId: (Optional) String. ID of the entity record to display the form for.
  • entityName: (Optional) String. Logical name of the entity to display the form for.
  • formId: (Optional) String. ID of the form instance to be displayed.
  • height: (Optional) Number. Height of the form window to be displayed in pixels.
  • navBar: (Optional) String. Controls whether the navigation bar is displayed and whether application navigation is available using the areas and subareas defined in the sitemap. Valid values are: "on", "off", or "entity".

However this doesn't seem to work for me. The ID of my form is 375DE297-C0AF-4711-A811-5F1663FAE5DA

Here's my code:

var entityFormOptions = {};
entityFormOptions["entityName"] = "contact";
entityFormOptions["formId"] = "375DE297-C0AF-4711-A811-5F1663FAE5DA";
Xrm.Navigation.openForm(entityFormOptions);

The new entity form opens; however it uses the default form, not the specified form.

I am running as a System Administrator and I have confirmed that I have access to all the forms for the specified entity so I don't think it is a form-security issue.

Has anyone tried this method of opening forms in Dynamics 365?


回答1:


That's looks like mistake in docs or bug in Dynamics.

Previous implementation (v8 and before) took formid in parameters object: https://msdn.microsoft.com/en-us/library/jj602956.aspx#openEntityForm

Although current documentation states that formId must be set in entityFormOptions it isn't actually honoured. But it is honoured when you put it to good old formParameters.

Thus this does the trick:

var entityFormOptions = {};
entityFormOptions["entityName"] = "contact";
var formParameters = {};
formParameters ["formid"] = "375DE297-C0AF-4711-A811-5F1663FAE5DA";
Xrm.Navigation.openForm(entityFormOptions, formParameters);

P.S. Note that lowercase "formid".




回答2:


we can also use the below code to open a particular entity form:

var entityFormOptions = {};
entityFormOptions["entityName"] = "nrw_contact";//Logical name of the entity
entityFormOptions["entityId"] = "nrw_contact_ID"; //ID of the entity record
entityFormOptions["formId"] = "CF8D885B-256D-43E6-8776-CBBB7AA88EF5"; //FormId
Xrm.Navigation.openForm(entityFormOptions);

Please refer this link for more details : https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openform



来源:https://stackoverflow.com/questions/49359342/xrm-navigation-openform-not-honouring-formid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!