Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

disable form based on a field value

(0) ShareShare
ReportReport
Posted on by

Hi,

i created a customized form for a SPO list and want to do the follwoing:

1. i have a table in which users should put entries, with a field called Version_ID, this field is based on a lookup field from the SPO list

2. there is a second table called Versions with Version ID and is Version Freezed? fields

3. user click on create new item in the SPO list

4. if the user select a version which is marked in the Versions table as freezed than the form should not be submited/ edited and a notification should be presented to the user.

 

will really appreciate your help.

thanks in advance.

Eyal

 

  • EP-29071004-0 Profile Picture
    on at
    Re: disable form based on a field value

    @v-xida-msft , thanks for both your replies. i fixed my formula according to your suggestion and it worked!!!

  • v-xida-msft Profile Picture
    on at
    Re: disable form based on a field value

    Hi @Perez ,

    Is the solution I provided above could fix your original issue?

     

    If the solution I provided above could fix your original issue, please consider go ahead to click "Accept as Solution" to identify my solution as helpful firstly.

     

    For your second question, you could consider open another new thread, and describe your issue there, then we could help you in that new thread.

     

    For your second issue, I found that there is something wrong with it. You should modify your formula as below:

    Set(VersionRecord, LookUp(Version_Ref_test,Version_ID=ChoiceVer.Selected.Value));
    If(
     !IsBlank(VersionRecord) && VersionRecord.'Is Version Freeze ?' = true,
     Notify("This version is in Freeze select another version, FORM CANT BE SUBMMITED", NotificationType.Error);Set(SubmitIt,false), // Modify formula here
     Set(SubmitIt, true) // Modify formula here
    )

    Note: If you want to set up a variable in a canvas app, you could only use Set function or UpdateContext function.

     

    If the issue still exists, please consider close this original issue, and then open another new thread to describe your issue, then we could help you there.

     

    Best regards,

  • EP-29071004-0 Profile Picture
    on at
    Re: disable form based on a field value

    Hi @v-xida-msft , your solution worked great, thanks for that.

    only thing that i didnt manage is the submission of the form.

    i dont have a submit b utton, as this is a customized form user need to click on the Save button.

    i tried to define a varaible on the Onvisible property of the form and than i edited your formula like this:

    Set(VersionRecord, LookUp(Version_Ref_test,Version_ID=ChoiceVer.Selected.Value));
    If(
    !IsBlank(VersionRecord) && VersionRecord.'Is Version Freeze ?' = true,
    And(Notify("This version is in Freeze select another version, FORM CANT BE SUBMMITED", NotificationType.Error),SubmitIt=false),
    SubmitIt=true
    )

    in addition i changed the OnNew in sharepoint integration to:

    If(SubmitIt=true, NewForm(SharePointForm1))

     



    but it didnt worked, anu ideas?

  • Verified answer
    v-xida-msft Profile Picture
    on at
    Re: disable form based on a field value

    Hi @Perez ,

    Is there a LookUp field in your Main SP List reference values from the Version_ID field in your first Table?

    Do you want to disable your Edit form once the user select a Version_ID option from the LookUp field ComboBox, which has been marked as freezed?

     

    I assume that the is Version Freezed? field is a Yes/No type column in your second table (SP List), please consider take a try with the following workaround:

    Set the OnChange property of the LookUp field ComboBox in your Edit form to following:

    Set(VersionRecord, LookUp(Versions, 'Version ID'= LookUpFieldComboBox.Selected.Value));
    If(
     !IsBlank(VersionRecord) && VersionRecord.'is Version Freezed?' = true,
     Notify('Your could not choose a Version Id which is Freezed, please re-choose again!', NotificationType.Error)
    )

    Set the DisplayMode property of each data card (except the LookUp field data card) in your Edit form to following:

    If(
     !IsBlank(VersionRecord) && VersionRecord.'is Version Freezed?' = true,
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

    Set the DisplayMode property of the "Submit" button to following:

    If(
     !IsBlank(VersionRecord) && VersionRecord.'is Version Freezed?' = true,
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

    In addition, you could also consider try the following formula directly:

    Set the OnChange property of the LookUp field ComboBox in your Edit form to following:

    If(
     LookUp(Versions, 'Version ID'= LookUpFieldComboBox.Selected.Value).'is Version Freezed?' = true,
     Notify('Your could not choose a Version Id which is Freezed, please re-choose again!', NotificationType.Error)
    )

    Set the DisplayMode property of each data card (except the LookUp field data card) in your Edit form and the "Submit" button to following:

    If(
     LookUp(Versions, 'Version ID'= LookUpFieldComboBox.Selected.Value).'is Version Freezed?' = true,
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • Rahber Profile Picture
    1,935 on at
    Re: disable form based on a field value

    Okey so it might be little difficult to explain

     

    So to replicate your scenario. I created a text field and everytime i enter a number in the text field i check if the number is present on SPO list. If its present i make the field uneditable.

     

    So Do following things.

     

    1) On the "OnChange" function of the field where you will enter the Version please add

     

     

    ClearCollect(CollectionName,"");ClearCollect(CollectionName,LookUp('SPO Source', TextInput1.Text exactin 'SPO Source'.VersionID));If(CountRows(CollectionName)=0, Set(Disable, DisplayMode.Edit),Set(Disable, DisplayMode.Disabled));

     

     

    2) Then on to the form you want to disable, go to its DisplayMode property and enter the variable Disable there.

     

    You would need to change the variables and fields as per your schema.

     

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 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard