Thanks both of you for the speedy responses, unfortunately both of these are erroring for me on save but both do work on testing giving the correct results:
Just to add a wrinkle here as we have had it with other expressions, this all works for 99% of names, but we have some names' mine included that will break the expression as we have users with ‘ in their names.
For instance, your above code works but only when the name is formatted without the ‘ in O’Brien
once its included we get:
Invalid Syntax - Missing ).
The fields are from our new starter form that is a free text field for the managers to type the new starter's name, is there a way of sanitizing the field to remove these sorts of symbols?
No worries, if not we will just have to do some coms on how format names when submitting the form.
I’ve just been working on this myself!
I’ve used the PowerShell app before any expression to remove the Apostrophe’s and spaces (as the “Van Persie” of this world would also not work in the Sam Account Name.) Things like Hyphens should be fine.
The below code should put it in the format of Uppercase first letter and lowercase rest of name.
so someone typing o’brien should return
OBrien
$name = "{{ticket.ri_70_cf_first_name}}"
$name = $name -replace '\s','' if ($name.Contains("'")){
Ah this is great i will give this a go and presumably we can with a little adaption use this to sanatize the JSON parser output fields as they always come through with ‘josh.obrien]’ which ends up causing fails on a bunch of the azure workflows
Hi @afautley
As you all know FS workflow Expression nodes are very particular about formatting and they will only accept single quotes ‘ in their expressions.
The reason your nested CONCAT worked (nice solve btw!) was bc CONCAT will only accept 2 values and that period (‘ . ‘ full stop) is considered as the 2nd value so the CONCAT errors when it sees the parameter (unacceptable 3rd value).
Hi Josh,
i see what you mean now, i never saved the code as i did not need it, but i got the same error message… Odd.
However, i added a second concat to seperate the Full stop ‘.’ and that seems to have fixed the issue.
so i think it might be due to the full stop working as an operand.
It worked when clicking the test button, but failed when clicking save??? not sure why it worked on the test but failed on the save button, surely the test is suppose to check for this sort of thing??
Anyway code works now, i just put it down to the full stop causing an issue…………...
Yeah seems like the test should fail if it won’t ultimately let you save your work!!!
I found that moving the full stop into the 1 segment produced the same error and I RTFM about CONCAT and realized that, unlike most CONCAT, you cannot have more than 2 values.
And if you remove the full stop, this does work and will save so…………...
I’ve just been working on this myself!
I’ve used the PowerShell app before any expression to remove the Apostrophe’s and spaces (as the “Van Persie” of this world would also not work in the Sam Account Name.) Things like Hyphens should be fine.
The below code should put it in the format of Uppercase first letter and lowercase rest of name.
so someone typing o’brien should return
OBrien
$name = "{{ticket.ri_70_cf_first_name}}"
$name = $name -replace '\s','' if ($name.Contains("'")){
Thanks for this was playing around with it this evening, when running via PowerShell it looks like the output name was formatted correctly but when done via the PowerShell node in the workflow it seems to be introducing a trailing space to the field.
I'm not well versed enough on PowerShell scripting to see if this was introduced via the script, but I've resolved via a trim expression on the result of the script execution, but just wasn't sure why it was getting introduced in the first placed.