Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error on CRM Fields, locks on fields get remove on form load

Posted on by 2,001

I have written a java-script which disable a field onSave of a form.

 Xrm.Page.ui.controls.get('FieldName').setDisabled(true);

It runs fine on form save but as soon as i reload the form. The disable field become enable and user can edit it again.

*This post is locked for comments

  • Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: Error on CRM Fields, locks on fields get remove on form load

    As guido pointed correctly, check getFormType then the field will be enabled in create mode

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Error on CRM Fields, locks on fields get remove on form load

    Yes check for the update and create mode then, like suggested.

  • Abhishek Gupta Profile Picture
    Abhishek Gupta 2,001 on at
    RE: Error on CRM Fields, locks on fields get remove on form load

    My Requirement is to make a field read only post creation of a record. if i make the java script to run on load, the field will always be disable. As it will make field read only whenever a user create a new record.

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Error on CRM Fields, locks on fields get remove on form load

    Hi,

    If you want to work that record in case of form load only you should write your code on onload, instead of onsave. When you will hit save your code will work because form is not reloaded (assuming you are using updated entity forms), so when you are reloading it means onload code is firing and as there is not code to disable it is not disabled.

    Hope it will help.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans