cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
tianaranjo
Level 8

If, Patch and UpdateContext

I have the following to update a SharePoint list (and collection) If the item doesn't already exist.  For the variable, varAlreadyReg, a popup will appear if the user has already signed up for the selected session.  I would like to also display the popup if the selected item is added to their schedule.  

I have tried inserting Set(varItemAdded, true) within the below If statement without success.  If I insert after the patch, it breaks the Lookup and allows duplicate sessions to be added.  I have tried placing it after the LookUp without success.  Any help would be appreciate.

If( 
IsBlank(LookUp(colMySessions, SessionId = ThisItem.SessionCode)),

Patch(
SessionConfirmation, 
{ 
UserBid: gloThisUserId,
SessionTitle: galAgenda.Selected.Title,
SessionId: galAgenda.Selected.SessionCode,
SessionDay: galAgenda.Selected.DayOfEvent,
SessionStartTime: galAgenda.Selected.StartTime,
SessionEndTime: galAgenda.Selected.EndTime,
SessionLocation: galAgenda.Selected.Location
}

),

Set(varAlreadyReg, true))

 

1 ACCEPTED SOLUTION

Accepted Solutions
jhall
Level 8

Re: If, Patch and UpdateContext

What you're dealing with is that PowerApps If/Then/Else statements are one value only (meaning you can only do one thing per IF or ELSE).  You can of course set your boolean before you do the work and then you can do this fairly easily:

 

Set(varAlreadyReg:!IsBlank(LookUp(colMySessions, SessionId = ThisItem.SessionCode)));
If( !varAlreadyReg, Patch(SessionConfirmation, {UserBid: gloThisUserId,SessionTitle: galAgenda.Selected.Title,SessionId: galAgenda.Selected.SessionCode,SessionDay: galAgenda.Selected.DayOfEvent,SessionStartTime: galAgenda.Selected.StartTime,SessionEndTime: galAgenda.Selected.EndTime,SessionLocation: galAgenda.Selected.Location}))

At this point, the variable varAlreadyReg could be used to display whichever popup you wanted.  I usually do popup's w/ booleans assigned to the Visible property of my dialog boxes anyway so you could at that point follow this w/ similar code to the following:

UpdateContext({showAlreadyReg:varAlreadyReg});
UpdateContext({showNowRegd:!varAlreadyReg});

Then your appropriate popup appears.  Set these two booleans to False for the screen's OnVisible event and set them to False when the user closes the Popup Windows and everything works slick as snot on a doorknob (as my football coach used to say).

View solution in original post

1 REPLY 1
jhall
Level 8

Re: If, Patch and UpdateContext

What you're dealing with is that PowerApps If/Then/Else statements are one value only (meaning you can only do one thing per IF or ELSE).  You can of course set your boolean before you do the work and then you can do this fairly easily:

 

Set(varAlreadyReg:!IsBlank(LookUp(colMySessions, SessionId = ThisItem.SessionCode)));
If( !varAlreadyReg, Patch(SessionConfirmation, {UserBid: gloThisUserId,SessionTitle: galAgenda.Selected.Title,SessionId: galAgenda.Selected.SessionCode,SessionDay: galAgenda.Selected.DayOfEvent,SessionStartTime: galAgenda.Selected.StartTime,SessionEndTime: galAgenda.Selected.EndTime,SessionLocation: galAgenda.Selected.Location}))

At this point, the variable varAlreadyReg could be used to display whichever popup you wanted.  I usually do popup's w/ booleans assigned to the Visible property of my dialog boxes anyway so you could at that point follow this w/ similar code to the following:

UpdateContext({showAlreadyReg:varAlreadyReg});
UpdateContext({showNowRegd:!varAlreadyReg});

Then your appropriate popup appears.  Set these two booleans to False for the screen's OnVisible event and set them to False when the user closes the Popup Windows and everything works slick as snot on a doorknob (as my football coach used to say).

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,752)