0 votes

Is it possible to use Regex to force a edit box parameter value to a specific format?

Forcing a user to input an alphanumeric as (###) ###-####

by (520 points)

1 Answer

0 votes
by (293k points)

Hello,

Unfortunately, there is no such possibility. However, thank you for the suggestion. We forwarded it to the corresponding department for consideration.

0

Is there a script that you are aware that can check the value of the field and then correct it with the necessary regex formatting?

0

Hello,

You can use an approach like the following with the below script in the If PowerShell script returns true condition. image.png

$regularExpression = "^[0-9]{3}\-[0-9]{3}$"
$Context.ConditionIsMet = "%param-myParameter%" -notmatch $regularExpression
0

I would prefer to not stop the action altogether. I suppose there isn't a way to rewrite the value in the script with the proper formatting? I am sure it's possible, but if that's programatically intensive I am fine researching on my own. Just didn't know if there were already existing conditions where you could pass the parameter value to another value and force it into compliance in between using regex.

0

Hello,

In general it is possible to change the format of a string using the Split method. However, it will require users to at least enter the proper number of digits into the parameter. As such, you can use a condition script to check the parameter length and cancel the custom command execution if it does not equal 10. Another script will take the parameter value and update it according to the required format before setting to a property. The following article should be helpful: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7.4. Finally, the custom command should look like the following: image.png If the approach does not meet your needs, please, describe the desired behavior in all the possible details with live examples and screenshots.

0

I will take a look. I think I can make something work with split. I'll post the results here.

On a sidenote, you could add the minimum character requirement on text parameters much like you do on property patterns. That would streamline things and remove the need for an additional script.

0

Hello,

Thank you for the suggestion. We forwarded it to the corresponding department for consideration.

Related questions

0 votes
1 answer

The use case we are looking for is providing a list of titles for users to choose from when initiating a re-hire. We already have a title property pattern established and would ... that we can manage the list in one place. Let me know and as always, thanks.

asked Nov 22 by msheppard (520 points)
0 votes
1 answer

We are wanting to display all values entered into a multi value text attribute in an email sent by Adaxes. What we've found is that only the first entry into the array ... Entry" Is there a way to reference the variable so that it displays all entries? Thanks

asked 22 hours ago by msheppard (520 points)
0 votes
1 answer

Hello, you helped us with a script to set the oof-message. Now we want to know, if it's possible to activate/deactivate the mail-forwarding option time-based. In the ... deactivate it accordingly on "param-abw-ende" Can you help me with that? Thanks Carsten

asked Nov 17, 2022 by lohnag (160 points)
0 votes
1 answer

Automation of user creation based on ServiceNow ticket creation.

asked Jan 24, 2022 by tdetmer (20 points)
0 votes
1 answer

I'd like to be able to either send an email report or export a CSV of all of the business rules carried out when a user is disabled. This would be ... Management Activity section but this includes things that weren't part of the disable operation. Thanks

asked Feb 19, 2020 by bavery (250 points)
3,574 questions
3,263 answers
8,282 comments
548,008 users