By default dynamics saves the last form used by a user for a certain entity. If the user later opens an entity of the same type dynamics uses the last used form.
Is there a way to force dynamics to always use a certain form?
According to this MVP's blog you can update UserEntityUISettings record for the specific owner and entity in a Post-Retrieve plugin to set the form to show.
You'll have to fetch and update the UserEntityUISettings which respects the following conditions:
ownerid equals plugin context's UserIdYou need to update the lastviewedformxml attribute to set the form you want users to see. The attribute is a string which should have this format:
"<MRUForm><Form Type=\"Main\" Id=\"FORM_GUID_HERE\" /></MRUForm>"
Form GUIDs can be grabbed from any exported solution's customization.xml which includes the entity.
There are some gotchas to be aware of:
UserEntityUISettings so if the query returns 0 records you shouldn't throw.You need to Write JavaScript to Switch form to default (or any other) form on load.
function switchForm() {
// Get current form's 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 these:
Xrm.Page.ui.formSelector item (client-side reference)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With