Dynamics CRM 2011 Rollup 12 Switch to Process Form Button

Paul Nieuwelaar, 29 January 2013

With Dynamics CRM 2011 rollup 12 (Polaris), and the new Process Forms, we are given an option to ‘Switch to Classic’ which allows us to switch from our Process Form to the Classic Form equivalent. One of the problems with this is that once you’re on the ‘classic’ form, there’s no button to take you back to the Process Form.

 Dynamics CRM 2011 Rollup 12 Switch to Process Form Button

If you close the ‘classic’ form, and then reopen the record again, the Process Form will open by default, but this is cumbersome, so I took it upon myself to add a button to the ribbon to allow us to switch back to the Process Form.

NOTE: If the Process Form doesn’t open by default when you open a record, make sure you’re on the entity-named form (e.g. ‘Contact’), and not the Information form. There are now 2 forms for every process-entity; the entity-named form is used by the Process Forms, and so the process form will only appear when viewing this form.

 Dynamics CRM 2011 Rollup 12 Switch to Process Form Button

I noticed the difference between opening a process form and a classic form was in the URL. A process form has ‘&rof=true’ at the end of the URL (read only form), whereas the classic form has ‘&rof=false’. If you leave this off entirely (like CRM does when opening the record from a grid) the default form will be displayed.

I’ve written some JavaScript to open the process form using the method mentioned above. I then added a new ribbon button to call this script. The JavaScript I used is as follows:

//name: entity name, id: entity guid, isForm: button clicked from form and not grid
function openProcessForm(name, id, isForm) {
    var clientUrl = Xrm.Page.context.getClientUrl();
    var url = clientUrl + "/main.aspx?etn=" + name + "&extraqs=%3fid%3d" + id + "%26&pagetype=entityrecord&rof=true";

    var target = isForm ? "_self" : "_blank"; //on a form we redirect, on a grid we open new 
    parent.parent.window.open(url, target);
}

NOTE: This may not function correctly from the outlook client, as it’s opening a new browser window. I investigated the Xrm.Utility.openEntityForm(name,id,parameters) approach by passing in parameters["rof"] = true, however this didn’t seem to work in all cases which is why I ended up doing it the way I did. There’s probably a better way to do it using ‘parent.parent.openStdWin’ or something else, so feel free to give it a go if it’s important to open from Outlook.

My form ribbon button is configured to pass the following parameters to my JavaScript function: PrimaryEntityTypeName, FirstPrimaryItemId, and ‘true’ (this last one is a custom bool value indicating if the button is on the form or on a grid). We can also add our button to the Homepage ribbon, so that we can open the process form every time, first time. For a Homepage ribbon button, pass the parameters: SelectedEntityTypeName, FirstSelectedItemId, and false.

This code is reusable and can be used on any entity that has a Process Form, all you need to do is add a button to your form ribbon and/or Homepage ribbon, and call this function when it is clicked.

 Dynamics CRM 2011 Rollup 12 Switch to Process Form Button

We can now switch between the Process form and our Classic form without having to close the window or do anything fancy. Note that this will even open the Process form if you are on the ‘Information’ form, as appose to the ‘Contact’ or entity-named form – in fact it will actually open the information form in Process mode, which is usually not possible.

Enjoy!