cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerStar321
Helper II
Helper II

How to check a SharePoint list and reject similar names. Remove spaces 'Team Proj 01', 'TeamProj 01', 'Team Proj01', 'TeamProj01'

Hi All,


We have a SharePoint list that we use for our company projects. The list includes a column with the project names in:

  • Team Project 01
  • Team Project 02
  • Team Project 03

We also have a PowerApp that users use to request a new project. The PowerApp first checks to see if the Project name exists in the SharePoint Project list using the code below

If(
CountRows(
Filter(
'New Project Site Request',
'Project Name' = TextInput1UsedToHoldProjName.Text
)
) = 0,
"Project Name: " & TextInput1UsedToHoldProjName.Text,
"A project with the same name already exists."
)

 

This works perfectly if the project names match exactly.

 

The user requests a new project with the name "Team Project 02". The SharePoint project list already has a project "Team Project 02" in it so the user receives the "A project with the same name already exists." error message.

 

What I am trying to get the check to do is to also reject a project name when the spaces are removed. For example, if they request a new project with the name "TeamProject02" (with no spaces), they will receive the "A project with the same name already exists." error message as "Team Project 02" appears in the SharePoint project list.

 

I have tried using Trim(TextInput1UsedToHoldProjName.Text), but it doesn't work. 

I hope you can help

Colin

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @PowerStar321 ,

Free-typed - so watch brackets, commas etc, but the structure you need should be something like this.

With(
   {
      wProject:
      Substitute(
         TextInput1UsedToHoldProjName.Text,
         " ",
         ""
      )
   },
   If(
      CountRows(
         Filter(
            AddColumns(
              'Project Site Request Form',
              "ProjectName",
               Substitute(
                  'Project Name',
                  " ",
                  ""
               )
            ),
            ProjectName = wProject
         )
      ) > 0,
      "Project Name: " & TextInput1UsedToHoldProjName.Text & Char(10) &
      "A project with the same name already exists."
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @PowerStar321 ,

Try

Substitute(
   TextInput1UsedToHoldProjName.Text,
   " ",
   ""
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi Warren,

 

That didn't work because we need to remove all spaces from the user's new Project name and the SharePoint list project name so they match.

 

For example, your code changes the PowerApp's new project name from "Team Project 02"  to "TeamProject02"

but the SharePoint list has the project name "Team Project 02".

 

What I would like to do is the user's new project name and the SharePoint list project name to remove all the spaces so they match and the user will receive "A project with the same name already exists." error message.

 

If(
CountRows(
Filter(
'Project Site Request Form',
'Project Name' = Substitute(
TextInput1UsedToHoldProjName.Text,
" ",
""
)
)
) = 0,
"Project Name: " & TextInput1UsedToHoldProjName.Text,
"A project with the same name already exists."
)

 

Thanks

Hi @PowerStar321 ,

Free-typed - so watch brackets, commas etc, but the structure you need should be something like this.

With(
   {
      wProject:
      Substitute(
         TextInput1UsedToHoldProjName.Text,
         " ",
         ""
      )
   },
   If(
      CountRows(
         Filter(
            AddColumns(
              'Project Site Request Form',
              "ProjectName",
               Substitute(
                  'Project Name',
                  " ",
                  ""
               )
            ),
            ProjectName = wProject
         )
      ) > 0,
      "Project Name: " & TextInput1UsedToHoldProjName.Text & Char(10) &
      "A project with the same name already exists."
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi Warren 

 

I am trying your code but I am getting an error message. I hope you can help

 

Error01.PNG

 

 

Error02.PNG

Hi @PowerStar321 ,

I suggested you watch commas and brackets - one comma missing after 'Project Name' - now fixed. I have also altered the bottom message to include a line break.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks Warren,

 

That worked like a treat !

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (5,624)