cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aaronjmill
Frequent Visitor

Patching last submitted record choice columns during OnSuccess

Hi. I'm pulling my hair out. I've got a SP list custom form that's designed to create new records for employee changes. Two of these columns are Combobox controls that pull items from columns in another SP list. What I'm envisioning is the user filling out the form, clicking submit, the two Combobox values being put into a Collection, the form submits, then the Patch function will pull the last submitted form and patch the two columns in question with the values stored in the Collection before clearing it out and resetting the form.

 

aaronjmill_0-1656609741533.png

 

Here's my OnSelect (forgive the lack of accessible names) :

Collect(Collection3, {'New Department': DataCardValue7.Selected, 'Status Change': DataCardValue6.Selected});
SubmitForm(SharePointForm1)

 

And this is my OnSuccess for the form (SharePointForm1):

Patch('Employee Changes',LookUp('Employee Changes', SharePointForm1.LastSubmit), {'New Department':Collection3.'New Department','Status Change':Collection3.'Status Change'})
;
Clear(Collection3)
;
Notify("Request successfully submitted!",NotificationType.Success);Navigate(MainPage,ScreenTransition.Fade)

 

I get this runtime error when trying to submit:

aaronjmill_2-1656609834337.png

 

 

I know something is wrong with the Lookup, but I don't know the proper syntax to fix it. I'm also pretty positive I'm calling on the Collection3 items incorrectly but again, I've had very little luck finding google results on my specific scenario. Any help you can provide would be great. Thank you!

3 REPLIES 3
Alex_10
Super User
Super User

@aaronjmill 

 

do you want to create a new record in 'Employee Changes' list?

Or you want to update an existing record there?

If update, how your master SP list relates to 'Employee Changes' list?

aaronjmill
Frequent Visitor

Thanks for the reply. Trying to create a new record, then patch two fields in that same record immediately afterwards. The master list is the 'Employee Changes' list.

Alex_10
Super User
Super User

@aaronjmill 

 

'New Department' and 'Status Change' are text columns?

 

if yes:

 

Collect(Collection3, {'New Department': DataCardValue7.Selected.Value, 'Status Change': DataCardValue6.Selected.Value});
SubmitForm(SharePointForm1)

 

 

 

Patch('Employee Changes',LookUp('Employee Changes', ID = SharePointForm1.LastSubmit.ID), {'New Department':First(Collection3).'New Department','Status Change': First(Collection3).'Status Change'})

 

 

 

EDITED: you may need replace .Value with a name of info you want to be used.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,826)