Prevent Dynamics CRM 2011 from using the last form used
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 contextUserId
- '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'tthrow
. - 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
source to share
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:
source to share