Skip to main content
Nintex Community Menu Bar
Solved

EndsWith validation

  • July 20, 2022
  • 5 replies
  • 57 views

Karin_EM
Forum|alt.badge.img+1

Hi, We are creating a Digital Good Outwards pass. In form user can add approver (people picker field - in SharPoint list = "Authorized approver")

However only employees can approve.  Directory also contains contractors (name /C) and contracted services workers (name /CS). I want to add a validation in the form that when "authorized approver" ends with "/C" or "/CS" message pops up that only employees an approve the form. I tried with Endswith but this does not work or I did something wrong. 

EndsWith("Authorized approver", "/C")

Best answer by Garrett

Hi @Karin_EM 

 

The value in the People Picker field "Authorized Approver" is actually the Login ID.

It doesn't contain the Display Name. As such, your function

EndsWith("Authorized approver", "/C") will always evaluate to False.

 

Use the userProfileLookup function to obtain the Display Name (which contains the /C or /CS). 

userProfileLookup("Authorized approver", "PreferredName") 

 

The final function should look something like below

EndsWith( userProfileLookup("Authorized approver", "PreferredName"), "/C")

 

@JRoberts suggests using the Contains() function. I agree! This is actually better because if the Display Name has a space e.g. "Garrett /C ", the Endswith() function will not evaluate as you intended. 

Again, this would also work but you still need to use the userProfileLookup() function first.

Contains( userProfileLookup("Authorized approver", "PreferredName"), "/C")

 

Below is a form with the People Picker, 2 Calculated Value fields and their formulas. 

 

Cheers

 

PS: Name and Email photoshopped. I don't work for Nintex... yet 

5 replies

JRoberts
Nintex Employee
Forum|alt.badge.img+12
  • Nintex Employee
  • July 20, 2022

Hi Karin,

 

Would the contains() function work you instead of endsWith()? My initial guess is that the endsWith() function is battling against the way SharePoint stores a value for the Person and Group column in the background. I think what you see onscreen for that column is a bit different than the value that is stored behind the scenes. 

 

Jason


Garrett
Forum|alt.badge.img+16
  • Scout
  • Answer
  • July 20, 2022

Hi @Karin_EM 

 

The value in the People Picker field "Authorized Approver" is actually the Login ID.

It doesn't contain the Display Name. As such, your function

EndsWith("Authorized approver", "/C") will always evaluate to False.

 

Use the userProfileLookup function to obtain the Display Name (which contains the /C or /CS). 

userProfileLookup("Authorized approver", "PreferredName") 

 

The final function should look something like below

EndsWith( userProfileLookup("Authorized approver", "PreferredName"), "/C")

 

@JRoberts suggests using the Contains() function. I agree! This is actually better because if the Display Name has a space e.g. "Garrett /C ", the Endswith() function will not evaluate as you intended. 

Again, this would also work but you still need to use the userProfileLookup() function first.

Contains( userProfileLookup("Authorized approver", "PreferredName"), "/C")

 

Below is a form with the People Picker, 2 Calculated Value fields and their formulas. 

 

Cheers

 

PS: Name and Email photoshopped. I don't work for Nintex... yet 


Karin_EM
Forum|alt.badge.img+1
  • Author
  • Novice
  • July 22, 2022
Thank You!

Karin_EM
Forum|alt.badge.img+1
  • Author
  • Novice
  • July 22, 2022
Thanks!

Karin_EM
Forum|alt.badge.img+1
  • Author
  • Novice
  • July 22, 2022
Thanks for your help. It works with contains !