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