Prevent Dynamics CRM 2011 from using the last form used

By default, the speaker retains the last shape used by the user for a specific object. If the user subsequently opens an object with the same dynamic type, it uses the last used shape.

Is there a way to make the dynamic always use a specific shape?

+3


source to share


2 answers


According to this MVP blog, you can update the entry UserEntityUISettings

for a specific owner and entity in the plugin Post-Retrieve

to set the form to show.

You will need to obtain and update UserEntityUISettings

one that meets the following conditions:

  • ownerid

    equal to the plugin context UserId

  • 'objecttypecode' is equal to the entity type code (number, not string)

You need to update the attribute lastviewedformxml

to set the form you want to see. The attribute is string

to be in this format:



"<MRUForm><Form Type=\"Main\" Id=\"FORM_GUID_HERE\" /></MRUForm>"

      

The form GUID can be removed from any exported solution customization.xml

that includes an object.

There are some mistakes to be aware of:

  • This plugin is sandboxed (so it's ok), but it interacts with an undocumented attribute, so make sure it works after any update (it should, but you never know ...)
  • "Special" users like SYSTEM don't have an entry in UserEntityUISettings

    , so if the query returns 0 entries, you shouldn't throw

    .
  • I suspect users will no longer be able to manually modify forms ...
  • This will be a plugin to retrieve, it may slow down the search
+6


source


You need to write JavaScript to switch the form to the default (or any other) form on load.

function switchForm() {

// Get current form Label
var item = Xrm.Page.ui.formSelector.getCurrentItem();
itemLabel = item.getLabel();

if (itemLabel != "Information")
{
  //load Information form
  var items = Xrm.Page.ui.formSelector.items.get();
  for (var i in items)
  {
    var form= items[i];
    var formId = form.getId();
    var formLabel = form.getLabel();

    //Check condition either on ID or Label from Form
    if (formLabel == "Information")
    {     
      form.navigate();
    } 
  }
} 

      



Please check the following:

Xrm.Page.ui.formSelector element (client side reference)

+3


source







All Articles