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)

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

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • Community Member Profile Picture
    on at

    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

    Use just

    yoursomenamespace.formContext = context;

  • Community Member Profile Picture
    on at

    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?

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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

    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;

           }

       }

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