1

I have been using the technique in the following post:

Xrm.Navigation.openForm not honouring formid

which has beeen working great in the Classic Interface.

I have updated my JavaScript to the following:

function OpenSpecificForm(primaryControl)
    {
        const FORMID = "A696976B-EA8A-42F3-B4DC-F35DC9204D58";                      

        var formContext       = primaryControl;
        var parameters        = { formid: FORMID };
        var entityFormOptions = {};
        entityFormOptions["entityName"] = "new_entity_name";

        var recordId = formContext.data.entity.getId();                    
        var recordName   = formContext.getAttribute("new_name").getValue();    

        if (recordId != null)   { parameters["new_targetentityfieldid"] = recordId; }
        if (recordName != null) { parameters["new_targetentityfieldname"] = recordName; }

        Xrm.Navigation.openForm(entityFormOptions, parameters);
    }

and set ribbon workbench as follows:

Crm Parameter

This code continues to work as expected in the Classic UI but doesnt seem to work in the new Unified Interface. The entity form opens but opens the last one CRM remembers and NOT the one I have specified in the formId.

Has anyone managed to open a specific form in the new UI?

  • Have you tried with "formId" instead of "formid"? The parameter name changed when Xrm.Utility.openEntityForm was replaced by Xrm.Navigation.openForm – Federico Jousset Nov 21 '18 at 09:31
  • Thanks for replying, unfortunately changing the parameter to formId doesn't help. It stops it working in both the old and new UI. – Bharat Premji Nov 22 '18 at 23:29

1 Answers1

0

I can see a couple of potential problems with your code.

The first one is related to how the form context is being generated because it actually needs to be obtained using the getFormContext method (documentation seems wrong) from the primaryControl object:

var formContext = primaryControl.getFormContext();

The second one is the parameter is the formId parameter name, which according to documenation should be written using capital I. It might no be a problem, but remember that the json spec states the following:

All member names exchanged between the Client and the Server that are considered for matching of any kind should be considered to be case-sensitive. The terms function, method, and procedure can be assumed to be interchangeable.

Federico Jousset
  • 1,661
  • 14
  • 21
  • Hi, adding getFormContext() works in the old UI, however in the UI I get a script error: primaryControl.getFormContext is not a function. – Bharat Premji Nov 22 '18 at 23:31
  • when using the ribbon and passing the primaryControl to your js function, use the primaryControl object as though it were the formContext. See https://stackoverflow.com/a/54012344/44815 – Raj Rao Jan 03 '19 at 21:24