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 365 | Integration, Dataverse...
Suggested Answer

Make a field enabled only on create, and read-only in other states

(0) ShareShare
ReportReport
Posted on by 37

in an entity ive set a Max Students Number field, i need to make it editable only when creating the form, and make it read-only right after saving the form

how to do that?

when i set the field as read-only i cant edit it at all when creating a new form, i need to be able to set a value to it on create - then change it to read-only

i saw setsubmitmode but did not understand how to use it 

here's what im stuck at so far in writing the function thats supposed to do it: (if possible without code id wish to know as well)

function disableFieldOnSave(Context)
{
    var formContext = Context.getFormContext();
    var maxStudentsNumberField = formContext.getAttribute("opu_maxstudentsnumber").getValue();
}
I have the same question (0)
  • Suggested answer
    MicroDynamicalCRM Profile Picture
    37 on at

    Update Edit:

    i've just read about GetFormType()

    now i know what to do:

    get the form type and setDisabled to false when the formtype value is "create" , and true elsewhere.

    problem solved

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    As MicroDynamicalCRM said, you can use getFormType to get the form type, you can refer to the following official documents:

    getFormType (Client API reference) in model-driven apps - Power Apps | Microsoft Docs

    pastedimage1631580769326v1.png

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

  • Suggested answer
    JyotiYadav Profile Picture
    40 on at

    Hi,

    You need to check the formtype using formContext.ui.getFormType(). docs.microsoft.com/.../getformtype

    If formtype  value is 1 i.e Create, you can enable the field formContext.ui.controls.get("your field name").setDisabled (false);

    else you can disable your field formContext.ui.controls.get("your field name").setDisabled (true); .


    Please mark as verified if the answer is useful.

  • Suggested answer
    Carlos Eduardo Fontolan Profile Picture
    on at

    Hello,

    I hope you are doing well.

    Also is possible to use security profile of fields such as docs.microsoft.com/.../field-level-security.

    In this situation is ensured that user can't change your rule, based on JavaScript can be changed on DEVTools on browser.

    Kind Regards,

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 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans