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)

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

I have the same question (0)
  • Verified answer
    Joseph McGregor Macdonald Profile Picture
    597 on at

    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

  • Suggested answer
    khoait Profile Picture
    450 on at

    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.

  • Community Member Profile Picture
    on at

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

  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • Verified answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    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).

  • Verified answer
    Maryam Profile Picture
    315 on at

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

  • Maryam Profile Picture
    315 on at

    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

  • Maryam Profile Picture
    315 on at

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

  • Maryam Profile Picture
    315 on at

    No unfortunately it doe snot work for create

  • Maryam Profile Picture
    315 on at

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

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