Skip to main content

Am trying to clean up a PreferredName userProfileLookUp using the “Replace” runtime function in a calculated value control.

The PreferredName comes in like Joe Smith (CompanyIdentifier - 6) where the content between the parenthesis can change.  I want to just end up with Joe Smith.

In a workflow, I use the Regular Expression action to Replace the text with nothing.  The regular expression match I use is:

\((/^)]+)\)

Works flawlessly.  But when I use the same regular expression in a calculated value:

replace(userProfileLookup(Current User,"PreferredName"),"\((a^)]+)\)","")

 

I end up with ) instead of Joe Smith

Any suggestions on why the regular expression would be different?

FYI - trying to avoid using JS on form if at all possible to enhance down the road support.

Hi @bgarvey 

 

That \((\^)]+)\) regex should definitely work, I managed to use it successfully: 

 

But I was able to recreate your issue by hard coding the pattern into the function, definitely not expected behaviour:
 

 

Seeing as variables work better perhaps it is an issue the form runtime causing a calculation to happen that modifies the regex because it does appear to think it is some kind of formula, I was able to get the form to show me what it is converting \((i^)]+)\) into and that does appear to be correct resulting in ((n^)]+)), it is removing the \’s, Reason? I am not sure, I think perhaps it is thinking the string is escaped in some way.

 


That lets try double escaping the regex and see if that works better which it does indeed:

"\\((>^)]+)\\)"

 

TLDR:

Please use replace(userProfileLookup(Current User,"PreferredName"),"\\((e^)]+)\\)","")

 

Hope this helps

Jake


@Jake Thanks!  I really appreciate the prompt reply!  Works like a charm in my calculated value control.

Since I will be leveraging this info multiple times in my form, I set up a Form Variable and low and behold it works like a charm!


@Jake 

Follow up!  If I was using this on a multi-select people field, what change would I need to make to the reg expression? So I would end up with

Joe Smith; Bob Doe; Sally Brown; from a person field EndUsers

I am assuming that replace(userProfileLookup(EndUsers,"PreferredName"),"\\((\^)]+)\\)",";") would only catch the first person’s replacement text…

Do I have to go a whole different way since it is an array?

Thanks again and appreciate ya!

 


Hi @bgarvey 

 

As the people output (EndUsers) would return a collection, userProfileLookup I don’t think will work because it would be:

replace(userProfileLookup(kJoe Smith; Bob Doe; Sally Brown;],"PreferredName"),"\\((\^)]+)\\)",";")

there is no profile for “Joe Smith; Bob Doe; Sally Brown;” as this is a singular lookup. 

this is the output you can expect.

There is only one option if you must return the names for a people control with multiple choice enabled.

 

Don’t use a multiple choice people control, instead use a single choice people control inside a repeating section, that way you can use the formula described above but honestly its not very good UX. 

 

Is there a particular reason that you need to display names on the form considering they already exist in the people field itself? 

 

Jake


@Jake 

I have a very large classic form that I have tabbed using a navigation panel (a choice field shown as buttons) that hides and shows panels depending on the button selected.  Each business group works on their “tab”, but some information needs to be displayed on multiple tabs as it is valuable information for more than one group (but not all or I would put in the header).  Mostly it is string or date info (Project Number, Due Date, etc.) but occasionally it is a person group field. 

All but one of them is not multi-select, so what we came up with works, as the users just need to know the info, not change it.

I was thinking ahead and wanted to be prepared for the scenario where a field may need to be displayed in multiple places.

I could just create a workflow to loop through the collection, query the LDAP, bring back the property and the use the reg edit, and write it all back to a text field.  Would not be real time like a Named Control, but I think that would work in a pinch.

Just trying to limit unnecessary workflows or workflows that only fire on a particular field change.  I could explore JavaScript, but am trying to stay as close to out of the box to help future people supporting the form...


Hi @bgarvey 

Completely understand, definitely an interesting use case and I would love to see it at some point, It might me something to explore as you come across the need, sadly this one might have to be JS, there may be no other way.

 

Saying that the newer forms designer in the cloud is much better and handling this scenario but we have moved away from one form hub design as a concept your form appears to use, now we display individual forms for each team ensuring we can control viewpoints for each person, this allows for a much more tailored user experience showing only the information they need and nothing else. imagine it like “heres a hammer and nail, go hit that it into that board” vs “heres a workshop, figure out what I want you to do” sometimes too much information is a lack of clarity.

 

Jake


We are licensed for just about everything Nintex (on-prem and cloud), but the nature of my clients, regulatory compliance, keeps me relegated to on-prem.

I take it there is not an option to have multiple forms associated to a single list for Nintex for SharePoint (specifically SharePoint 2019).

I am pondering having a workflow create custom EditForm links so that I can grab a URL parameter, then JS on the form to set the tag.

Alternately, I could hide each “unused” panel by using fn-ismemberofgroup and set up individual SP groups for each Business Area.  Quick question - we only assign AD groups to SharePoint groups - does fn-ismemberofgroup work with AD groups?  Or do the people have to explicitly be listed in the SharePoint group?

 


Hi @bgarvey 

You can indeed have multiple forms for a single list but this wont work on a single item.

Each list can contain multiple content types and each content type can have its own form. 

 

Depending on the use case this might work really well for you.

If you’d like I am happy to explore solutions with you, If you want please reach out to me via your Nintex Account Manager to set up a call. 

 

Jake. 


@Jake I may take you up on that!  I will play around a little more but then will reach out through our AM.

I have used content types on SharePoint lists in the past to allow similar but not identical content to co-exist in a list, but the intricacies of this process probably does not fit that model well. Users from different groups all play a part on managing the same list item.

I did run a quick test, and the fn-IsMemberOfGroup does appear to be able to traverse AD groups, so that is a positive!


Reply