Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

formContext as a Ribbon function parameter in Unified Interface

Posted on by Microsoft Employee

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
    Community Member Microsoft Employee 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
    a33ik 84,323 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
    Community Member Microsoft Employee 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
    a33ik 84,323 Most Valuable Professional on at
    RE: formContext as a Ribbon function parameter in Unified Interface

    Use just

    yoursomenamespace.formContext = context;

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    a33ik 84,323 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans