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)

How to make a page in read only for a current User

(0) ShareShare
ReportReport
Posted on by 65

Hi All!

My question is how to make a page in read only for the current user using Javascript.

something like this:

function function() {
var userId = Xrm.Page.context.getUserId();
var owner= Xrm.Page.getAttribute("ownerid").getValue();
var ownerID = owner[0].id;

// if user#owner
if (userId != ownerID) {
    //make a current user in readonly
    }
}


Do you have any idea?

thank you in advance

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi,

    give read permission in user level in security role.

    Best Regards,

    Kannan. S

  • MilindP Profile Picture
    1,019 on at

    Disable all fields 

     

    // if user#owner
    if (userId != ownerID) {
    //make a current user in readonly
     var controls = Xrm.Page.ui.controls.get();
                for (var i in controls) 
                {
                    var control = controls[i];
                    if (control.getName() != "" && control.getName() != null) 
                       {
                        if (!control.getDisabled()) {control.setDisabled(true); }
                      }
                }
              
    }
    
  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Lissan,

    You can give that user permission to read optimized only form or you can just limit it to the user read level in security role

    Or you can use script to make it disable, but again you need also to disable the ribbon since the script wont work for ribbon.

    crmexplorer.com/.../disable-wnable-fields-sections-tabs-and-the-whole-form-in-crm-2011

    mscrmbynic.wordpress.com/.../crm-2011-to-disable-all-fields-in-a-form-through-javascript

    social.microsoft.com/.../haw-to-disable-form-fields-and-ribbon-in-crm-2011-using-javascript

    Thanks

  • Royal King Profile Picture
    27,686 on at

    Use below line of code to disable all fields in a form.

    Xrm.Page.ui.controls.forEach(function (control, index) { try { control.setDisabled(true); } catch (e) { } });

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