Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

While opening user in classic getting script error element.setDisabled is not a function in crm 365 uci

(0) ShareShare
ReportReport
Posted on by 2,667

Hi All,

I am using below script & calling onload of user record:

And If i am opening this user record from owner lookup on lead record its working fine.But in classic ui page if opening user record getting below error:

pastedimage1657099154812v1.png

var User_Retail = window.NameSpace || {};

///Onload Functions call
User_Retail.OnLoad = function (executionContext) {
    User_Retail.disableForm(executionContext);
};
///Make form read only
User_Retail.disableForm = function (executionContext) {
    "use strict";
    try {
        if (executionContext !== null && executionContext !== undefined) {
            let formContext = executionContext.getFormContext();
            if (!User_Retail.IsSystemAdmin()) {
             
                formContext.ui.controls.forEach(function (element) {    
                    console.log('element', element);
                        if (element.getName() !== "" && element.getName() !== null) {
                            element.setDisabled(true);
                        }                  
                });
            }
        }
    }
    catch (e) {
        common_Retail.openAlertDialog("Ok", e.message);
    }
};
///Check System admin role
User_Retail.IsSystemAdmin = function () {
    "use strict";
    try {
        //let formContext = executionContext.getFormContext();
        var roles = Xrm.Utility.getGlobalContext().userSettings.roles;
        if (roles === null || roles === undefined) return false;
        var hasRole = false;
        roles.forEach(function (item) {
            if (item.name.toLowerCase() === "system administrator") {
                hasRole = true;
            }
        });
        return hasRole;
    }
    catch (e) {
        common_Retail.openAlertDialog("Ok", e.message);
    }

};

Any idea am doing wrong over here

Thanks,

Jharana

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

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 > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans