web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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;

    }

    }

    }

    }

  • Community Member Profile Picture
    on at

    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;

    }

    }

    }

    }

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    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.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans