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)

Locking entire Form when it has a specific Status Reason

(0) ShareShare
ReportReport
Posted on by

I have a Purchase Order entity which has various Active Status Reasons.  Once it's gone through the prerequisite states, it's Status Reason = Active; so Status = Active and Status Reason = Active.  When that condition exists, I need all of the fields on the form to be locked so the Purchase Order can't be changed; it's now a contractual agreement.  We should be able to Append To it with payments that decrement it's balance, but the user should not be able to change it.

Is there an OOTB way to do that?  I know that when you change the Status to Inactive, it llocks everything down; but I need the Status to remain Active, just locked.

Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You can create a Business Rule or develop JavaScript that will lock your Sales Order form based on current state.

  • Suggested answer
    alf Profile Picture
    17,915 on at

    Hi Debra -  If you have crm 2013 or later, business rules should be able to do this:

    www.powerobjects.com/.../creating-if-then-else-logic-in-crm-2013-business-rules

  • Cyclefitness Profile Picture
    on at

    Business rules require me to go field by field.  That's so time-consuming. Are there any tricks to making it go faster?

  • Suggested answer
    alf Profile Picture
    17,915 on at

    An aerodynamic mouse ?  

    The alternative is javascript......depending on the scenario and number of fields is much faster to write up than the point and click business rules.  

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I would suggest to write a really simple JavaScript. Here is part of solution for you - stackoverflow.com/.../disabling-all-fields-on-a-form-in-crm-2015

  • Verified answer
    Community Member Profile Picture
    on at

    Sounds like a misunderstanding here. The whole point of using an Inactive status is to make a record read-only - and not just through the form but any other "user led" approach (eg bulk edit, or export/reimport). Your scenario sounds ideal for this - lock a record once it is signed, sealed, cast in stone, etc, using Status=Inactive, Status Reason = Contract Agreed (or whatever words you want). You could then have further Inactive status reasons for "Paid in Full" or "Cancelled" (for example), and drive these with workflows.

    So why can't you Append To this record? Usually because the OOB Lookup view is configured to filter for Active records so users cannot see them. So if you change your Lookup view for your custom entity "Purchase Order" you ought to be able to create a payment record and choose the correct (Inactive) PO in the lookup.

    In fact, taking this thought one step further - do you allow users to create payments against POs before they become locked? If not, then on the Payment record form, you should configure the lookup field to not use the PO lookup view, but rather use the "Inactive POs" view, to help users to find suitable records. You could even create a custom view to show POs that are Inactive (or some specific status reasons) and have an outstanding balance > 0 and use that view in the lookup field on the payment record - I assume you don't want payments mis-filed against old POs that are already paid off?

  • Inam Profile Picture
    215 on at

    Using javascript you can loop controls collection on form to disable them.

  • Suggested answer
    Community Member Profile Picture
    on at

    Here is a JScript function that sets everything to read-only/locks the fields:

    function ReadOnly() {
        if (add your conditions here) {
            Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
                var control = Xrm.Page.getControl(attribute.getName());
                if (control) {
                    control.setDisabled(true)
                }
            });
        }
    }


    I use this for my custom entity as well.

  • Verified answer
    Pranesh M Juwale Profile Picture
    1,196 on at

    Hi Debra,

    function ReadOnly ()

    {

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

       for (var i in controls)

       {

           var control = controls[i];

           if (!control.getDisabled())

           {

               control.setDisabled(true);

           }

       }

    }

    try this

  • Cyclefitness Profile Picture
    on at

    Yes, Adam; that's what I've done.  I, too, was considering INACTIVE status.  And on further thought, I think I will move the POSO through its lifecycle using a business process flow and upon each move, the Status will be updated by the workflow.  I need to lock it so no users can change it, so the workflow will have to be the only entity that can change it.

    Thanks for validating what I was thinking, Adam!

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