Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Xrm.Page.ui

(0) ShareShare
ReportReport
Posted on by

Hello Everybody,

I am pretty new to the world of Microsoft Dynamics 365 CRM and have been practicing JavaScript Statements in the demo version.

I am using the below mentioned JavaScript Code in the Form Onload event but it is not giving me the desired output. Can anybody guide me or correct me here?

function testmethod()

{

Xrm.Page.ui.formSelector.getCurrentItem();

}

*This post is locked for comments

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Xrm.Page.ui

    ok, please make sure

    1. Your form changes are published, you can try to republish your entity.

    2. Check if your entity forms have form level security if yes, make sure you have required security roles.

    First you should be able to see form selector if you have two forms then your code will work fine.

  • RE: Xrm.Page.ui

    No..I have not been able to see the name of the form through form selector

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Xrm.Page.ui

    Just to confirm, you are able to see form selector when you open form ??

  • RE: Xrm.Page.ui

    Hi Meenoo,

    I have created 2 forms under one entity 1. New Addition Form 2. Revised main form and when i am putting the below mentioned code in Form Onload event , then its giving me nothing when i open a new form.

    function testmethod()

    {

    var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();

    }

  • Suggested answer
    meenoo Profile Picture
    meenoo 7,316 on at
    RE: Xrm.Page.ui

    Hi Ekansh,

    How many forms do you have? Are you getting a different form name than what you expect or are you getting an error?

    You have it correct in the script. If your entity has only one form defined, .getCurrentItem() will return null

    var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();

    Thank you.

  • RE: Xrm.Page.ui

    Hi Matt,

    I used the below mentioned code on form onload event to fetch the Name of the form but was not able to get the name. Is there anything wrong in the code?

    function testmethod()

    {

    var selector=Xrm.Page.ui.formSelector.getCurrentItem();

    var label=selector.getLabel();

    }

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Xrm.Page.ui

    In addition to that keep in mind when only one form is available it will return null.

  • Suggested answer
    - Matt Bayes - Profile Picture
    - Matt Bayes - 890 on at
    RE: Xrm.Page.ui

    Hi Ekansh,

    What is your desired output? This line of Javascript will return a FormSelector object, at which point you can get various properties of it via methods:

    var selector = Xrm.Page.ui.formSelector.getCurrentItem();

    var id = selector.getId();                --> GUID of the form

    var label = selector.getLabel();      --> Name of the form

    Hope this helps!

    Matt Bayes

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…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

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,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans