cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Responsive Resident
Responsive Resident

How to reference a current SP list item that was just created?

Hello,
I would like to develop a solution that would allow users to edit SP list's item details they have created.

Scenario:
1. User fills in the Canvas App form;

2. User clicks Submit button

OnSelect = 
Patch(
    MT,
    varFormData,
    form_Form.Updates,
    form_Form1.Updates
);
If(
    IsEmpty(Errors(MT)),
    Notify(
        "Success",
        NotificationType.Success
    );
    Navigate(screen_Confirmation),
    Notify(
        First(Errors('MT')).Message,
        NotificationType.Error
    )
)

3. In the screen_Confirmation user has an option to click continue editing information button, which currently has OnSelect = 

//Reset forms
ResetForm(Form);
ResetForm(Form1);

//Set variable that holds details associated to the form
Set(
    varFormData, ThisItem
);

//Navigate to Registration form screen
Navigate(form_MaterialRegistration)


Set(varFormData, ThisItem); < this unfortunately returns an error.  Not sure how to give the context of the recently created SP List item.. Perhaps someone experienced similar situation? 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User III
Super User III

@mantastg08876 

Patch returns the record that was patched, so you can gather that in a snapshot variable:

Set(lastRecord, Patch(....

Then lastRecord will have the record you just patched.

 

I would recommend using the built in SubmitForm rather than multi-patching forms with the Updates as you lose the ability to catch errors and success as well as validation of the data prior to submit.  These are all very valuable features that you will not get with the patch.

 

Since you are trying to split a form, you might be interested to watch my video on splitting forms without losing the EditForm features.  It will be valuable to have the features that are built into EditForms at your disposal.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Responsive Resident
Responsive Resident
11 REPLIES 11
Super User III
Super User III

@mantastg08876 

Patch returns the record that was patched, so you can gather that in a snapshot variable:

Set(lastRecord, Patch(....

Then lastRecord will have the record you just patched.

 

I would recommend using the built in SubmitForm rather than multi-patching forms with the Updates as you lose the ability to catch errors and success as well as validation of the data prior to submit.  These are all very valuable features that you will not get with the patch.

 

Since you are trying to split a form, you might be interested to watch my video on splitting forms without losing the EditForm features.  It will be valuable to have the features that are built into EditForms at your disposal.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

hi @RandyHayes , thank you!. I followed your video guide, but somehow get stuck when I set Item function to my master form to Patch(varFormData, form1.updates, form2.updates). The error says that the property cannot reference itself or other properties affected by its value.

varFormData is set for Item function in form1 and form2

Super User III
Super User III

@mantastg08876 

You might have missed something then.  I never use Patch for forms in the video.  In the video the master form has the OnSuccess action that sets the global variable that all the forms use to the last submitted record. 

Please review again and let me know where you get stuck.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes , 
i'm sorry if I confused something.. just wanted to clarify if the Patch function in the screenshot does men to combine all the information that is filled in the form and return a record based on that combination? 
https://youtu.be/2E4FXNPLVXw?t=1010 I get stuck here, unfortunately

mantastg08876_0-1610406481782.png

 

Super User III
Super User III

@mantastg08876 

Yes, that formula is what combines the sub-forms to the master form.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Responsive Resident
Responsive Resident
Super User III
Super User III

@mantastg08876 

Don't confuse that video with what I am doing in mine.  Mine USES the EditForm features, his does not.  He is using that Patch function which completely skips all the functionality of the Form.  Not really a good way to go.  And again, DO NOT confuse or combine what he does in that video with mine.  They are two separate approaches.

 

Are you still having an issue?  What are you stuck on?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes , thank you very much for your comment.

Do I understand correctly that your option is to have one master from, where you would have all data fields which are filled in with information entered in other forms? 

Super User III
Super User III

@mantastg08876 

Yes - one Master form in the app.  The app would contain ALL of the fields.  Any fields that are found in a separate form would be made non-visible, but they would still exist in the form.

The forms are all "wired" together through the Item property on the master form.

After that, you would SubmitForm on the master form and you will have all of the form features available to you.  The other video uses a Patch method that completely bypasses the functionality of the Form and you lose all of that.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (36,708)