Xrm.Navigation.openForm not honouring formid in Unified Interface

1.1k views Asked by At

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?

1

There are 1 answers

2
Federico Jousset On

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.