Skip to main content

Notifications

Announcements

No record found.

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

  • Rajesh Chungath Profile Picture
    467 on at
    RE: interactive interface lock Date Field

    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

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: interactive interface lock Date Field

    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)

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: interactive interface lock Date Field

    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.

  • Community Member Profile Picture
    on at
    RE: interactive interface lock Date Field

    I need your help please

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans