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 can I make my form as read only

(0) ShareShare
ReportReport
Posted on by

hi,

When I am cancelling purchase order I want to make it read only  as shown in below image.

readonlyform1.jpg

I donot want to fetch all the fields(Controls) one by one and make it as read only....I want to make a whole form as read only .As working in all othe existing entity like order...etc..

How can I achieve this using js?

*This post is locked for comments

I have the same question (0)
  • Rajkumar Rajaraman Profile Picture
    on at

    Yes, It's possible

    Use this:

    function ReadOnly ()

    {

        var controls = Xrm.Page.ui.controls.get();

        for (var i in controls)

        {

            var control = controls[i];

            if (!control.getDisabled())

            {

                control.setDisabled(true);

            }

        }

    }

  • Rajkumar Rajaraman Profile Picture
    on at

    Try this also:

    mscrmtechie.blogspot.in/.../set-crm-form-as-read-onlydisabled-in-ms.html

  • Community Member Profile Picture
    on at

    Hi rajkumar...

    I have tried this before..but through this  it will lock  all the controls and make it read only...i know through that it cannot allow to edit any fields but it willnot look proper .and also not display a line as i showed in my question in the bottom of my page

  • Suggested answer
    Sean Michel Profile Picture
    340 on at

    Hi NikkiShah,


    To do this, you'll need to change the Status of the record. 

    http://sumedha8.blogspot.com/2011/11/state-statecode-and-statuscode-change.html

    http://guruprasadcrm.blogspot.com/2013/02/change-record-status-using-javascript.html

    If you must use JavaScript, you can find the method above. I'd suggest you consider workflow if possible, specifically, real-time workflow. It'll be easier to implement and maintain.

  • Royal King Profile Picture
    27,686 on at

    Update the record status to be inactive that will do what you want.

  • Alok Sharma Profile Picture
    340 on at

    Hi Rajkumar,

    i tried above approach in crm 9.0 but got below error

    TypeError: Object doesn't support property or method 'getDisabled'

    Please advice if it is not supportable in crm 9.0. Also advice if you have any other approach.

    Thanks.

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    If you have subgrid or iframe, you will get this error. Extra checks will avoid this.

    var controls = Xrm.Page.ui.controls.get();

       for (var i in controls) {

           var control = controls[i];

           if (control.getDisabled && control.setDisabled && !control.getDisabled()) {

               control.setDisabled(true);

          }

       }

    stackoverflow.com/.../7920473

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi NikkiShah,

    It is better to set a form to read only by changing the records status then it is to use JavaScript.

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