cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Techgallagher
Helper I
Helper I

Patch a new record to a list from a form

Hi, so I have this form where people can go and create a new project, it works just as you'd expect. It lets users fill out the fields and then on submission it will reflect their inputs on a backend SharePoint list called Project Requests. However, there is another list called Project Tracker where I want to be able to track the status of projects and I'd like it so that when a user submits the project request form, I can patch a new record into the project tracker list as well. The record on the project tracker does not need all the fields to be filled in, mainly just the project ID field so that if a user were to look at that value they could go to the ID of the project request list and find the project that is being tracked. 

 

Here is the request screen and the ID data card is there, it is just hidden b/c the user doesn't need to see that. 

Techgallagher_0-1602183457380.png
This is the formula for the submit button. I've tried a bunch of things, but I either get errors like title is required or I can't get the right data type, etc. 

Techgallagher_1-1602183535685.png

Here is the Project tracker list: Project name is the title field, project id is a number data type, progress is a choice field, priority is also a choice field, assigned to is a number field because I'm also connecting that to employee ids and notes is multi lines of text

Techgallagher_2-1602183652483.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Techgallagher 

First, consider moving anything except SubmitForm out of your Submit button OnSelect and move whatyou are trying to do into the OnSuccess action of the Edit form.  This way your formula will only apply once the form submit is successful.  With your formula currently, if there is an error in the submit, your patch would still happen...probably not what you want!

 

Then in the OnSuccess action - this formula:

Patch('Project Tracker', Defaults('Project Tracker'),
  {
    Title: Project_Req_Form.LastSubmit.'Project Name',
    ProjectID: Project_Req_Form.LastSubmit.ProjectID,
    ...and so forth for the remaining columns you want...
  }
);
Navigate('Success Screen', Fade)

 

That should give you what you want.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Techgallagher 

First, consider moving anything except SubmitForm out of your Submit button OnSelect and move whatyou are trying to do into the OnSuccess action of the Edit form.  This way your formula will only apply once the form submit is successful.  With your formula currently, if there is an error in the submit, your patch would still happen...probably not what you want!

 

Then in the OnSuccess action - this formula:

Patch('Project Tracker', Defaults('Project Tracker'),
  {
    Title: Project_Req_Form.LastSubmit.'Project Name',
    ProjectID: Project_Req_Form.LastSubmit.ProjectID,
    ...and so forth for the remaining columns you want...
  }
);
Navigate('Success Screen', Fade)

 

That should give you what you want.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @Techgallagher ,

Select the Form and Set OnSuccess Property.

Patch(SpList, Defaults(SpList), {Column1: Value, Column2: Value})

VijayTailor_0-1602184389134.png

 

Thanks,

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."-Vijay

 

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (4,478)