Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How can I make my form as read only

Posted on by Microsoft Employee

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

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: How can I make my form as read only

    Hi NikkiShah,

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

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: How can I make my form as read only

    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

  • Alok Sharma Profile Picture
    Alok Sharma 340 on at
    RE: How can I make my form as read only

    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.

  • Royal King Profile Picture
    Royal King 27,686 on at
    RE: How can I make my form as read only

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

  • Suggested answer
    Sean Michel Profile Picture
    Sean Michel 340 on at
    RE: How can I make my form as read only

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I make my form as read only

    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

  • Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How can I make my form as read only

    Try this also:

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

  • Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How can I make my form as read only

    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);

            }

        }

    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans