Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Setting form as default with j script

(0) ShareShare
ReportReport
Posted on by

Hi,

In a default entity I have several forms that I created, and have set one as a default, but whenever a user selects a form it leaves it there. For example if "Form A" is the default but a user selects "Form B" it will stay on form B until we select form A.

Does anyone know any java script I can use to fix this?

Much appreciation!

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Setting form as default with j script

    Hi,

    This code will work but usually, we set a particular form as default form based on some logic (field value).

    See the links below.

    community.dynamics.com/.../157879

    saikrishnayadav.blogspot.in/.../set-default-form-in-ms-crm.html

    Hope this helps.

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: Setting form as default with j script

    Hi,

     there is a good example here:

    community.dynamics.com/.../javascript-form-navigate

     It also verifies if currently selected form is, actually, different from what you are trying to navigate to..

     Problem is, this kind of script should be utilizing some kind of condition. For example, if there is a particular value selected into an optionset field, you migth want to choose a specific form.

     Otherwise, once you call that function, it will navigate to the "client" form.. If you do it in the "onload" of all the forms, then it will constantly be getting you to the "client" form no matter what, and it's, likely, not exactly how you want it to be.

  • RE: Setting form as default with j script

    Would the following script work if the form I would like to set is "client"?

    function setMyFormAsDefault() {

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

    var myDefFormName = “Client”;

    // 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;

    }

    }

    }

    }

  • RE: Setting form as default with j script

    Would the following script work if the form I would like to set is "client"?

    function setMyFormAsDefault() {

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

    var myDefFormName = “Client”;

    // 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;

    }

    }

    }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans