Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to disable a field after Save with out closing the form in CRM365

(0) ShareShare
ReportReport
Posted on by 315

I would like to disable a field after first save.

The case is:

I have an application form which has application type(Picklist).
The moment I save the Application I want to disable the Application Type so users can not change it. 

I put a function on the form load to disable the Application Type if Xrm.Page.ui.getFormType() != 1

This works correctly if I save and close the application record and reopen it again and Application Type field will be disabled.

The problem that I have is for the first Save. If user saves the record and do not close the form, the application Type field will not be disabled :(. I debugged the code it and after record is saved the onload event of the form will be kicked again but the form type is still 1 (which is create).

Any help how can I achieve this will be really appreciated!

Please note that my Legacy rendering in the system setting is set to yes as well.

*This post is locked for comments

  • Maryam Profile Picture
    Maryam 315 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Thanks this should work although as I mentioned below I did something else. I just simply checker if the field has value disable it

  • Maryam Profile Picture
    Maryam 315 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    No unfortunately it doe snot work for create

  • Maryam Profile Picture
    Maryam 315 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Thanks but It does not work for create scenario as field has not been saved yet in onsave

  • Maryam Profile Picture
    Maryam 315 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Thanks for your help this should work.

    I did something else which is simple and I thought I can share. On form load I checked if the field has value I disabled it

  • Verified answer
    Maryam Profile Picture
    Maryam 315 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    It does not other thank I reload the form which causes more issue

  • Verified answer
    Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Yes, Joseph answer is relevant for me. Usually I will add modified on in hidden section and I will register modified on change to call Form_OnLoad function in Javascript. The logic behind that is when you save the form, plugin will trigger and come back to the UI to change the values that changes on plugin (in this case modifiedon).

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Hi,

    I would simply call the function on the onload event if the Xrm.Page.ui.getFormType() != 1 and always call it in the onsave event.

    It should do the trick

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Rather than putting the function onLoad of the form, would putting it onSave of the form not work?

  • Suggested answer
    khoait Profile Picture
    khoait 450 on at
    RE: How to disable a field after Save with out closing the form in CRM365

    Hi Maryam. Not sure why the form type is still 1, I'll double check and let you know. In this case, you may want to try adding a function for OnSave event in the form and apply the same logic to disable the Application Type.

  • Verified answer
    RE: How to disable a field after Save with out closing the form in CRM365

    You should be able to achieve this using an onchange JavaScript event on the createdon or modifiedon field

    If you add an onchange method for this field it should fire after the record is first saved, and using some appropriate logic you should be able to set the field as read only

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans