web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

interactive interface lock Date Field

(0) ShareShare
ReportReport
Posted on by

On the interactive interface on Dynamics CRM (9.1.0.643), I need to lock a Date field with JS, below my code: 

OnChangeStatus: function (executionContext) {
        if (typeof executionContext.getFormContext === "function") {
            formContext = executionContext.getFormContext();
        } else {
            formContext = executionContext;
        }
        var status = formContext.getAttribute("acc_reportstatuscode").getValue();
        if (status == 805230001)
            formContext.getControl("acc_date").setDisabled(true);
    },

If you put this method on an OnChange event of another field, the Date field lock does not work, however if the same method runs in the OnLoad event of the page, in this case the Date field lock is well done.

PS: the same method works well on all other fields

*This post is locked for comments

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

    I need your help please

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Gobji,

    You statement contradicts with each other-

    "If you put this method on an OnChange event of another field, the Date field lock does not work"

    "PS: the same method works well on all other fields"

    If the method works on load and pother field then there shouldn't be any problem with the method/code. You have a logic to disable the date only if the report status is "805230001" so I suspect its not the field or event which is making it to work or not, it is the status code which is driving the disable. Check this.

    You can also debug your script and see if the code is executing fine or not.

    docs.microsoft.com/.../debug-javascript-code

    Hope this help.

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

    When you attach this method to onchange event of control in form editor, make sure to check two checkboxes - Enable & Pass the form context as first parameter.

    Check if this method is hit using debugger;

    Verify any errors in browser developer toolbar console (F12)

  • Rajesh Chungath Profile Picture
    467 on at

    Please debug and check . If you are unable to find the file type "debugger" on your method and refresh the page after opening developer toolbar (f12). 

    May be status value is not matching

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans