cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Perez
Helper V
Helper V

disable form based on a field value

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Rahber
Super User
Super User

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.

 

v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Perez
Helper V
Helper V

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?

v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Perez
Helper V
Helper V

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

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,314)