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

Patch function instead of SubmitForm function broke my other patch function

Hello!

What changed from SubmitForm to Patch function? I know the basic difference but here is the issue.

Earlier I was using SubmitForm to submit multiple forms to one data source. I realized, the best way is to use Patch() if using multiple screens for one data source. Below is the formula

 

 

Patch(
    'DataSource',
    Defaults('DataSource'),
    Form3.Updates,
    Form3_1.Updates,
    Form3_2.Updates
);
Notify("Form submitted successfully");

 

 

This works beautifully by creating just one record in the datasource table. But it breaks my other functionality. I had another form, which would use a different data source but should have a lookup of ID from previous datasource. The formula used was below:

 

 

ForAll(
    ColSelectedReq,
    Patch(
        'User Data Element',
        Defaults('User Data Element'),
        {'Unique ID': Form3_2.LastSubmit.ID},
        {'Data Element': Text('Data Elements')}
    )
)

 

 

 

This basically, creates a collection and save the records of a form to store in another SharePoint list, but also reference the unique ID generated from the previous forms. This was working with the Submit(form) button but stopped working after I used the patch function. 

Can someone please help?

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User III
Super User III

Hi @PoojaG ,

The LastSubmit() as the name suggests is based on the Submission of a Form with SubmitForm(), so it is not broken, you just have not submitted the form.

You can get the ID in a Variable with Patch like this

Set(
   ID2,
   Patch(
      'DataSource',
       Defaults('DataSource'),
       Form3.Updates,
   ).ID
)

I am not sure it will work on multiple as per your model.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted
Responsive Resident
Responsive Resident

@PoojaG as per my understanding you are capturing the submitted record's ID first. If yes, the syntax given was not correct try this

Set(id2, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates).ID);

If you want to capture whole record try this

ClearCollect(colPushedData, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates));

 

As per your syntax - it should look like this

 

Set(id2, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates).ID);

Notify("Form submitted successfully");

ForAll(ColSelectedReq,Patch('User Data Element',Defaults('User Data Element'),{'Unique ID': id2},{'Data Element': Text('Data Elements')}))

View solution in original post

7 REPLIES 7
Highlighted
Super User III
Super User III

Hi @PoojaG ,

The LastSubmit() as the name suggests is based on the Submission of a Form with SubmitForm(), so it is not broken, you just have not submitted the form.

You can get the ID in a Variable with Patch like this

Set(
   ID2,
   Patch(
      'DataSource',
       Defaults('DataSource'),
       Form3.Updates,
   ).ID
)

I am not sure it will work on multiple as per your model.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted

 As per your suggestion, I added that code to the patch function. It still doesn't work. 

Highlighted

@PoojaG ,

What does not work (are you not getting the ID back in the Variable)?

Highlighted

as per @WarrenBelz it should work. Try taking a  collection.

ClearCollect(colRecord,Patch( 'DataSource', Defaults('DataSource'), Form3.Updates, Form3_1.Updates, Form3_2.Updates ))

 

Please share the expression if it not working to have a better understanding

Highlighted

@WarrenBelz  Sorry I wasn't clear. Yes I didn't get the ID back

@krishnags , this is the modified code based on @WarrenBelz's post. 

Set(
    id2,
    Patch(
        'GHRIS Governance Request Form',
        Defaults('GHRIS Governance Request Form'),
        Form3.Updates,
        Form3_1.Updates,
        Form3_2.Updates
    ).ID;
    Notify("Form submitted successfully");
    ForAll(
        ColSelectedReq,
        Patch(
            'User Data Element',
            Defaults('User Data Element'),
            {'Unique ID': Form3_2.LastSubmit.ID},
            {'Data Element': Text('Data Elements')}
        )
    )
)

 

Highlighted
Responsive Resident
Responsive Resident

@PoojaG as per my understanding you are capturing the submitted record's ID first. If yes, the syntax given was not correct try this

Set(id2, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates).ID);

If you want to capture whole record try this

ClearCollect(colPushedData, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates));

 

As per your syntax - it should look like this

 

Set(id2, Patch('GHRIS Governance Request Form',Defaults('GHRIS Governance Request Form'),Form3.Updates,Form3_1.Updates,Form3_2.Updates).ID);

Notify("Form submitted successfully");

ForAll(ColSelectedReq,Patch('User Data Element',Defaults('User Data Element'),{'Unique ID': id2},{'Data Element': Text('Data Elements')}))

View solution in original post

Highlighted

@krishnags this works perfectly. My mistake was I was not using the new id2 variable in the patch function. thank you both @WarrenBelz  I will accept your solution. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,309)