cancel
Showing results for 
Search instead for 
Did you mean: 

AMFTF: One of my best SharePoint form tips

For a good start of this new year, I decided to share one of my best tips related to SharePoint forms.

The cause of this tip is that I am not fond of using the SharePoint list item ID field to uniquely target an item. It often works fine until the solution has to be migrated (but there are migration tools which preservce the list item ID). I rather use a custom field containing a unique ID. But SharePoint has no way to automatically create an unique value in a custom field which often results in using the list item ID field (I am not fond of using a workflow for this too).

With the introduction of customizing forms with PowerApps, a mechanism is available to add an unique value in a custom field.

This mechanism works as follows:

Using the patch function first in the "OnSuccess" event of the form. When the "OnSuccess" event is fired, the ID of the created item is known and can be used via (The first name "SharePointForm" depends on your situation):

SharePointForm.LastSubmit.ID

When adding a patch statement, the custom field can be updated with the ID of the list item. This results in a custom field containing an unique value.

An example statement is given below.

Patch('Employees', First(Filter('Employees', ID=SharePointForm.LastSubmit.ID)), {employeeID: SharePointForm.LastSubmit.ID}); ResetForm(SharePointForm); RequestHide()

The form should be configured such that the custom field ('employeeID' in the example above) is not available ofcourse. Also don't forget about the "Quick edit" "security hole".

This mechanism can also be used to make your own calculated fields! For SharePoint it will be a field of type "Single line of text" where the content is genereated by PowerApps.

This mechanisme has 2 potential drawbacks depending on your situation to be aware of:

  1. An extra version is created when versioning is enabled.
  2. It could result in a workflow being fired twice.
Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim