Power Community

Power Community

How to add SharePoint ID to custom ID in Power Apps

I decided to write How to add SharePoint ID to custom ID in Power Apps post as recently get this question during project and was surprised that people are using only Power Automate for this task…

Table of content:


Firstly, I would like to cover why Power Automate shouldn’t be your pick. The scenarios which I saw were using Automated Cloud Flow with When item is created trigger. With such configuration, I would say following two points are making it not the best choice:

  1. There is the delay between creation of the item and when Cloud Flow is starting – bad UX, User don’t see custom ID value post item creation
  2. Cloud Flow is updating the item in the context of the active connection (in most cases the Flow Owner) so the Modified By is showing a different person which for some process and auditing is not ideal

Where the Power Apps methods will resolve both of the above pain points. I will demonstrate in this blog two methods how to create custom ID based on the SharePoint ID via Power Apps.

Option 1 – Form control

I will start with a quicker and easier to explain method. I know that Forms control might be not liked by so advance Users, but for many scenarios Forms control is enough.

Note: I’m making the assumption that in your project you already have a column created where you will be storing your custom ID. For me it will be column CustomID (yup, originality 9/10 😜).


  • Select Form control (for me, it is Customized form but it will work in the same way for Standalone Apps)
  • Find OnSuccess property

All operations after SubmitForm function should be done in the OnSuccess property, it is a good practice.

  • Add following lines:
    {vLastSubmit: SharePointForm1.LastSubmit},
        {CustomID: $"D{vLastSubmit.ID}"}


NOTE: I left the Custom ID in the form, but of course in the PROD scenarios it should be hidden.


For the full picture, I will add more context, first on the high level:

  • ResetForm and RequestHide are part of the Default configuration of the Customized forms, you will NOT see them in the Standalone applications
  • SharePointForm1 is the standard default name for the Customized forms if I would created Standalone App or add the Form control first time default would be Form1
  • LastSubmit is one of the Form control properties which keeps data of the last time which was submitted. LastSubmit is why ever this method is working!

The LastSubmit is also awesome to show confirmation to the Users, that item with following ID has been created. There are many more use cases for LastSubmit usage, let me know your ideas.

  • With function has been added for better readability of the example, but I would recommend learning this function as it is super awesome. To learn With function, click here.

Now let’s I will jump to the details of the function:

  • In With function, I’m creation variable of the vLastSubmit and add to it SharePiontForm1.LastSubmit , so basically it is a variable with data of the item which was created.
  • In the Patch I’m firstly adding the data source, next vLastSubmit which is the record which I will update, lastly referring to the column which I want to update and provides its value.
  • Finally, I think it might be confusing how the string was formatted. It is new way of the concatination of the text in the Power Apps. If you want to learn more, click here.
    In my example, I’m just adding the prefix of the “D” and the SharePoint ID to the Custom ID column.

I hope it all make sense, if not please let me know I’m more than glad to add more context.

Option 2 – Own form & Patch

While I was making preparation to this blog, I was thinking that not only Form control might be used to create custom ID. The second option would be when I create my own form and to submit data, where I’m using Patch function.

I will use the same list as in the above example, so the list with Title & CustomID column only.


  • First, I generated the new Canvas Standalone app.
  • Then I connected it to the DemoOfCustomId list
  • To make it somehow useable I added four controls
    • lblTitle – text label control
    • txtTitle – text input control (removed Default value)
    • btnSubmit – button control (labeled Submit)
    • lblCustomID – text label where I will display value of CustomID

Functions added to the btnSubmit OnSelect:

        {Title: txtTitle.Text}
        {CustomID: $"D{varItem.ID}"}

I used Set function with the assumption in my mind that variable might be useful in other screens but UpdateContext will also work.

My finishing touch was update of the Text property in lblCustomID control:



NOTE: The SharePoint list on the right was refreshed by me manually to confirm changes and something funky happen with the navigation display… simply sorry for bad positioning of the display 😋


I did not have the access to the LastSubmit, so how this worked?

  • Patch function after execution is returning the data after successful submission. In that sense it worked like LastSubmit storing the data of the created record.
    • First Patch function use for second parameter Defaults to create new Record/Item
  • To keep and have access to the Record from Patch I used Set function, wrap it (Set) around Patch function.
  • The second Set is to get the refreshed (new version) of the updated Record
  • Second Patch is using varItem variable as the second parameter to push update = creation of the Custom ID

Hint – CustomID format

I was thinking that adding the D prefix as the custom ID won’t be very useful in the end of the day 🥹

One idea which pop up in my mind is to add some zero leading values, for instance custom id will always have 6 digits:

To get such result, change the previous value of the CustomID to:


As you see, Text function is also very powerful 😁


I hope you like How to add SharePoint ID to custom ID in Power Apps post and it will be useful for you.

My aim was to demonstrate an alternative method to the Power Automate. In my opinion, it is simplifying the architecture of such solutions and remove delay connected timer job.

If you liked this blog, maybe you will like also:How to use SVG to create spinner in Power Apps

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Locking down SharePoint so only Integrated App can be used

This is an issue that has been the subject of many questions and below is the series of processes...

More Articles Like This

- Advertisement -spot_img