Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

formContext as a Ribbon function parameter in Unified Interface

(0) ShareShare
ReportReport
Posted on by

Hello,

Just wondering how can I pass to a ribbon function the formContext so I can execute the getFormContext function. I am performing the call from the incident form.

I have this sorted in classic interface by passing the primaryControl as parameter. However, in UUI it's a different story as the object that is passsed as primaryControl doesn't expose such method:

errorUI.png

Any hints? 

Thanks,

Jorge.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Thanks Andrew.

    In my case I used it like this:

    MyNameSpace.Context = context._formContext;

    this MyNameSpace.Context provides me the ui object and others. So, in order to keep backwards compatibility with legacy UI, I have the following initiator, at least for the set of Xrm functions I am using in my webresources:

    Init: function (context) {

           try {

                // this line is for legacy UI

               Merkal.Context = context.getFormContext();

           }

           catch()

           {

               // this line is for Unified interface

               Merkal.Context = context._formContext;

           }

       }

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Jorge,

    I worked with passing of the context and it went smoothly for me. ui and all the stuff should be available without any tricks. Check following post - docs.microsoft.com/.../pass-dynamics-365-data-page-parameter-ribbon-actions

  • Community Member Profile Picture
    on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Thanks Andrew for your help.

    Unfortunately seems that it's not that easy. The whole code needs to be reworked. For instance, that context doesn't provide the ui object directly, like this:

    MyNamespace.formContext.ui.getFormType();  - note that MyNamespace.formContext is defined as passed primaryControl.getFormContext() -

    Using the direct context, this is how I get there:

    MyNamespace.formContext._formContext._ui.getFormType();

    Do you think I am missing something?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Use just

    yoursomenamespace.formContext = context;

  • Community Member Profile Picture
    on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Hi Andrew,

    I want the object that replaces Xrm.Page's.  primaryControl parameter doesn't expose the same functions and objects than Xrm.Page when taken in a Unified interface application. 

    This is the code snipnet that I need to replace:

    snip3.png

    Called from classic interface, I don't reach the catch block, and I can use that xxxx.formContext as a replacement for the deprecated Xrm.Page object. But on the other hand, this doesn't work for UUI. No configuration changes have been made and the form that triggers the script is the same. 

    snip3.png

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Jorge,

    What do you want to get from formContext?Based on my experience primaryControl is formContext so you have no need to call getFormContext to get it.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans