Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Patch function to write the value (list item ID) from a Global Variable



I'm creating an  "Enquiries App" for customers to submit a request for research to be done by our Library department.

There are 2 main Sharepoint lists called "Reference Desk Enquiry" and "Reference Desk Enquiry Admin".

The  "Reference Desk Enquiry" app allows anyone to submit a request, and the Admin list is for the Library researchers to use for the work to be done.


The first list needs to store the List item ID value of the Enquiry record in to a column called 'Reference ID', so that it can be referenced by the Admin Sharepoint list as a unique ID.

This is because all list data from the "Reference Desk Enquiry submitted" gets copied by a "Flow" into the Admin Sharepoint list.


All that being said, I’m trying to use the Patch function to write the value (list item ID) from a Global Variable into the field called 'Reference ID, in the Reference Desk Enquiry list.  


This is my patch function so far.....   

Patch('Reference Desk Enquiries',First(Filter('Reference Desk Enquiries',Reference_x0020_ID=varEnquiryID)))

The Reference ID columns is not the first one in the list, so I think that could be the issue.

See Attachment OnSuccess Function.jpg


The PowerApp creates the SP list record with my "Save" button below, using the OnSelect function of the Form.

It submits the form, notifies the user of success.

It also has a global variable called varEnquiryID that stores the ID of the list item, from the form using "LastSubmit.ID".

The variable does contain the correct ID number, so there is no issue with this..

Obviously the record needs to be submitted first so that the ID number can be recorded after the PowerApp OnSelect function has ran.


I have tried my patch function in the OnSelect function of the "Save" button on the main screen of the form, which is after the record has been written,

and also in the OnSuccess Function of the actual form, with no success, so far.

See Attachment OnSelect Function.jpg 


For your information:-

  The SP List is called 'Reference Desk Enquiries'

  The SP List column is called 'Reference_x0020_ID'

  The global variable is called varEnquiryID

  The form is called frmCreate_Ref_Desk_Enquiry 


I believe that I'm on the right track, and think it might have something to do with being able to refer to the correct record to update in the SP List, or the actual column itself.


I would appreciate any help that you can provide,




Community Support
Community Support

Hi @HollyHugo,


What is your current situation?

For new record creation, the patch () function should be written as:

Patch('Reference Desk Enquiries',
         Default('Reference Desk Enquiries'),
First(Filter('Reference Desk Enquiries',Reference_x0020_ID=varEnquiryID)))

For how to use the patch(), see:

Patch() in PowerApps




Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Michael

Thanks for your response.

The record has just been created by my powerapp, so I want to update a column with the ID of the new item created.

So its an update or modify an existing record.

I can capture the ID of the record just created by using the "lastsubmit;ID.

Just need to write that ID value into the column "Reference_x0020_ID "



Stewart - newbie at Powerapps

Not applicable

Hello @HollyHugo ,

As you solved them, I have a similar problem. I need to update the search ID of the child list in order to add records by referencing the parent ID.


I am trying it with the Path function, if it updates text and numeric fields, but the field ID (search ID in my child list) gives me the following message:
  "the type of this argument 'Id_header' Does not match expected 'Record' type argument"


thank you for your comments.




Is there a solution for this question because I have a similar problem and would like the solution.

thanks in advance

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

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

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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 (3,555)