Advertisements
Home > CRM 2011, JScript > Set desired form as default using script – CRM 2011

Set desired form as default using script – CRM 2011

I have an “Account” entity with multiple forms (i.e.,4 forms). My requirement is to set particular form as default form based on some logic.

Below is the script to set desired form as default.

function setMyFormAsDefault() {

// Set the form name you want to set as default

var myDefFormName = “ABC”;

// Get all available forms

if (Xrm.Page.ui.formSelector.items.get()) {

var forms = Xrm.Page.ui.formSelector.items.get();

var formId, formName;

for (var indxForms = 0; indxForms < forms.length; indxForms++) {

formId = forms[indxForms].getId();

formName = forms[indxForms].getLabel();

// Check form name and if it matches set current form as Default

if (formName == myDefFormName) {

forms[indxForms].navigate();

break;

}

}

}

}

  • Xrm.Page.ui.formSelector.items.get()” give us all available forms of the current entity
  • getId() & getLabel() gives the form GUID and Form name
  • “navigate()” loads the selected form

🙂

Advertisements
  1. techcop
    October 8, 2013 at 8:37 PM

    do you call it setting default form, will it prevent re loading form if the user chooses a different form??

    • August 19, 2014 at 3:47 PM

      Every “Navigate()” causes reload of the form.

  2. ekartika
    August 16, 2014 at 12:40 AM

    If I have multiple forms do I need to put this script on the OnLoad event for all of the forms (except default one)?

    • August 19, 2014 at 3:46 PM

      Hi,
      Script has to be registered on your first form based on the order.
      So by default form configured first in the order loads and the script kicks in and navigates the user to your desired form.
      FYI, We can specify the order of the forms using ‘Form Order’ option. Note that forms visibility depends on the user’ role.
      Thanks,
      Rajeev

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: