cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Philipp_S
Level: Powered On

Change form based on field value

Hi everyone,

 

I'm trying to prevent people of change an list item, if it has not the status "Pending". 

If I open an item with status "In Porgress", the editform shows up instead of showfrom.

 

OnEdit:

Refresh(SpeedTesting);
If(DataCardValue11.Selected.Value = "Pending" Or DataCardValue13.Selected.Value = "Pending",Set(SharePointFormMode,"EditForm");EditForm(FormEdit);Navigate(ScreenEdit,ScreenTransition.None),Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None))

 

OnView:

Refresh(SpeedTesting);Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)

Is it the correct apporach?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Change form based on field value

@Philipp_S 

I would suggest changing your code in two ways:

#1  Swap out the references to any DataCards with a direct reference to the SharePointIntegration

#2  Put the Navigate code in front of your code to change the form mode.

 

If(
    SharePointIntegration.Selected.your_status_fieldname11 = "Pending"
    Or SharePointIntegration.Selected.your_status_fieldname13 = "Pending",
    Set(SharePointFormMode,"EditForm");
    Navigate(ScreenEdit,ScreenTransition.None);
    EditForm(FormEdit), 
    Set(SharePointFormMode,"ShowForm");
    Navigate(ScreenView,ScreenTransition.None);
    ViewForm(FormView)
)

Refresh(SpeedTesting);
Set(SharePointFormMode,"ShowForm");
ViewForm(FormView);
Navigate(ScreenView,ScreenTransition.None)

 

In general though it looks fine.  Suggest you give your code a test.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

View solution in original post

Community Support Team
Community Support Team

Re: Change form based on field value

Hi @Philipp_S ,

Could you please share a bit more about your scenario?

Do you want the Edit form to show up only when the Status is "Pending"?

 

I have made a test on my side, please consider modify your formula as below:

OnEdit property of SharePointIntegration:

Refresh(SpeedTesting);
If(
   SharePointIntegration.Selected.StatusColumn1.Value = "Pending" || SharePointIntegration.Selected.StatusColumn2.Value = "Pending",
 
 Set(SharePointFormMode,"EditForm");EditForm(FormEdit);Navigate(ScreenEdit,ScreenTransition.None), 
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)
)

or

Refresh(SpeedTesting);
If(
   LookUp(SpeedTesting,ID = SharePointIntegration.SelectedListItemID, StatusColumn1.Value) = "Pending" || LookUp(SpeedTesting,ID = SharePointIntegration.SelectedListItemID, StatusColumn2.Value) = "Pending",
 
 Set(SharePointFormMode,"EditForm");EditForm(FormEdit);Navigate(ScreenEdit,ScreenTransition.None), 
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)
)

 

OnView property of SharePointIntegration to following:

Refresh(SpeedTesting);
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)

Note: The StatusColumn1 and StatusColumn2 represents the Choice type columns in your SP List, which may store the "Pending" value.

 

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

4 REPLIES 4
Super User
Super User

Re: Change form based on field value

@Philipp_S 

I would suggest changing your code in two ways:

#1  Swap out the references to any DataCards with a direct reference to the SharePointIntegration

#2  Put the Navigate code in front of your code to change the form mode.

 

If(
    SharePointIntegration.Selected.your_status_fieldname11 = "Pending"
    Or SharePointIntegration.Selected.your_status_fieldname13 = "Pending",
    Set(SharePointFormMode,"EditForm");
    Navigate(ScreenEdit,ScreenTransition.None);
    EditForm(FormEdit), 
    Set(SharePointFormMode,"ShowForm");
    Navigate(ScreenView,ScreenTransition.None);
    ViewForm(FormView)
)

Refresh(SpeedTesting);
Set(SharePointFormMode,"ShowForm");
ViewForm(FormView);
Navigate(ScreenView,ScreenTransition.None)

 

In general though it looks fine.  Suggest you give your code a test.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

View solution in original post

Community Support Team
Community Support Team

Re: Change form based on field value

Hi @Philipp_S ,

Could you please share a bit more about your scenario?

Do you want the Edit form to show up only when the Status is "Pending"?

 

I have made a test on my side, please consider modify your formula as below:

OnEdit property of SharePointIntegration:

Refresh(SpeedTesting);
If(
   SharePointIntegration.Selected.StatusColumn1.Value = "Pending" || SharePointIntegration.Selected.StatusColumn2.Value = "Pending",
 
 Set(SharePointFormMode,"EditForm");EditForm(FormEdit);Navigate(ScreenEdit,ScreenTransition.None), 
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)
)

or

Refresh(SpeedTesting);
If(
   LookUp(SpeedTesting,ID = SharePointIntegration.SelectedListItemID, StatusColumn1.Value) = "Pending" || LookUp(SpeedTesting,ID = SharePointIntegration.SelectedListItemID, StatusColumn2.Value) = "Pending",
 
 Set(SharePointFormMode,"EditForm");EditForm(FormEdit);Navigate(ScreenEdit,ScreenTransition.None), 
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)
)

 

OnView property of SharePointIntegration to following:

Refresh(SpeedTesting);
Set(SharePointFormMode,"ShowForm");ViewForm(FormView);Navigate(ScreenView,ScreenTransition.None)

Note: The StatusColumn1 and StatusColumn2 represents the Choice type columns in your SP List, which may store the "Pending" value.

 

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

Super User
Super User

Re: Change form based on field value

@Philipp_S 

Did our posts solve your issue?  If yes, please Accept as Solution.  You can mark more than one post if needed.

Philipp_S
Level: Powered On

Re: Change form based on field value

Yes, the Edit form shows up only if the column status is "Pending".

Your and @mdevaney provided solutions are totally fine for my needs or do you have any other suggestions?

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,066)