Contents

Say NO to creating the same SharePoint item TWICE with PowerApps

 

One thing that is pretty nice in SharePoint is that, you cannot have a file with the same name in the same location (library). Unless it has a different extension: For example, sample.docx and sample.pdf can coexist in SharePoint. But you cannot have twice sample.pdf.

However, you can have the same ITEM name in a SharePoint list! Wouldn’t it be useful to not have “duplicates” in a SharePoint list when submitting data from PowerApps? And although those items might be different when looking at their other metadata, sometimes we don’t want items to have the same title. And that’s exactly what we’re going to talk about today 🙂

 

The Goal

For this example, we’re going to have an app to submit Service Requests. More specifically requests the creation of SharePoint sites, Teams teams, or else. Our goal is to prevent users from submitting a request for the creation of a SharePoint site, where the site has already been created for someone else with this title, but the user creating the request is not aware of that!

 

PowerApps Form

In my app, I have a Form where the Site Title field is Text Input. This is where the user will have to enter the title for the site they want created. That control is named DataCardValue1.

In the card itself (called Site Title_DataCard1), I have a label called lbl_ErrorSiteNameAlreadyExists (or you may use the default “ErrorMessage” label if you think it suits your needs). It’s placed just underneath the text input control.
 

/images/powerplatform-screenshots/avoid-creating-spo-items-twice-with-powerapps-img1.png
 

Formulas

In the Text property of this lbl_ErrorSiteNameAlreadyExists control, we’re going to say “Name already exists. Please choose another one.”. This way, when users type a title for their site, we’ll do a lookup into our SharePoint list to check if the name is already taken.

Then, in the Visible property of this same control, we’re going to enter our lookup formula:

1
If(!IsBlank(LookUp(<ENTER-YOUR-SPO-SOURCE-LIST>, <ENTER-YOUR-SPO-COLUMN-NAME> = <TEXT-INPUT-CONTROL-USED-BY-THE-USER>.Text)), true, false)

 

So mine would look like this:

1
If(!IsBlank(LookUp('SharePoint Site Creation', 'Site Title' = DataCardValue1.Text)), true, false)

 

One last formula to add is on the OnChange property of DataCardValue1 (the user text input field):

1
If(!IsBlank(LookUp('SharePoint Site Creation', 'Site Title' = DataCardValue1.Text)), lbl_ErrorSiteNameAlreadyExists.Visible)

 

And we’ll make sure the DelayOutput property of DataCardValue1 is set to true.

 

Because this is a show-stopper for submitting the request, you can change the Color property to Red (hence using the default ErrorMessage control might be useful because already configured), and you could also add a formula in the DisplayMode of the Submit button to be disabled when our label is showing 😉 Just use lbl_ErrorSiteNameAlreadyExists.Visible in your condition.

 

Results

Note that this is NOT case sensitive. Therefore, the same title written uppercase or lowercase doesn’t matter. This is still taken ✅
 

/images/powerplatform-screenshots/avoid-creating-spo-items-twice-with-powerapps-img2.png
 

/images/powerplatform-screenshots/avoid-creating-spo-items-twice-with-powerapps-img3.png
 

Thanks for reading! 🙂