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 365 | Integration, Dataverse...
Answered

Remove the deprecated Xrm.Page.getAttribute function

(0) ShareShare
ReportReport
Posted on by 5

Hi All

  The company hopes to remove some functions that have been abandoned in the current version and replace them with the latest code .
But I noticed that use the executionContext.getFormContext() Instead of xrm.page.getgetAttribute method, I need to use executionContext as input parameter.
When I check the current JScript , I find the following code :

var sunRiseCo = sunRiseCo || {};
sunRiseCo.util = function () {

    var CACHE = {};

    function getAttr(attr) {
        var attrObj = Xrm.Page.getAttribute(attr);
        if (!attrObj) {
            var msg = 'miss attribute \'' + attr + '\' !';
            Xrm.Navigation.openAlertDialog(msg);
            throw new Error(msg);
        }
        return attrObj;
    }
    return {
        'attribute': {
            'get': getAttr

        }
    };

}();

At present, sunRiseCo.util.attribute.get()  is used in lots of pages , If i want to replace the Xrm.Page.getAttribute(attr) without change the input parameter of the getAttr() fuction, Is there any solution ?

I have the same question (0)
  • Verified answer
    WMeschalin Profile Picture
    75 on at

    Hello BlueinLife,

    Effectively you will need to adjust the Function that is called on the form to statically assign formContext, something along the lines of:

    sunRiseCo.util = function () {
       var formContext;
       // This function is called via onLoad on the form
       function onLoad(executionContext) {
           formContext = executionContext.getFormContext();
       }
       function getAttr(attr) {
           var attrObj = formContext.getAttribute(attr);
           // etc. replace Xrm.Page with formContext from here.
       }
    }

    I hope this helped!

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 51 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans