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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,342)