Tag Key & Value Policy question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I'd like to know how to create a Tag Key & Value Policy that would verify:
1- the value is not empty,
2- allow any value between 0001 and 99999
3- can only be 4 or 5 digits
Ex: "ApplicationID = 7345 would be compliant, but 953 wouldn't.
Can someone help me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi @pguillemette ,
Yes, you can accomplish this using a Tag Key & Value Policy (specifically within ServiceNow's Tag Governance or CI Tagging frameworks) by utilizing a regular expression to enforce the format.
Based on your requirements:
Value cannot be empty.
Value must be exactly 4 or 5 digits.
Value must be numeric (effectively covering the 0001–99999 range).
The Recommended Regex
To enforce your requirements, use the following regular expression in your policy definition:
^[0-9]{4,5}$
Why this works:
^ : Matches the beginning of the string.
[0-9] : Ensures only numeric digits are allowed.
{4,5} : Ensures the total length is strictly 4 or 5 characters long.
$ : Matches the end of the string.
Compliance Examples:
✅ Valid: 0001, 7345, 9999, 10000, 99999
❌ Invalid: (empty), 953 (too short), 123456 (too long), ABCD (non-numeric), 12A45 (contains letters)
Architectural Implementation Tip:
When configuring this in the Tag Governance or Cloud Tagging module:
Validation: Ensure the policy is set to "Enforce" rather than "Warn" if you want to prevent non-compliant tags from being saved to the CI or record.
Testing: Always test this against a dummy CI record or a non-production tag policy before deploying to production. Tag policies can be global in scope, so a typo in the Regex could potentially impact a wide array of existing records.
If you are applying this specifically to a Catalog Variable or a Form Field rather than a systemic Tag Policy, please let me know, as the implementation steps (UI Policy vs. Data Policy) would differ slightly!
Hope this helps!
Please mark this answer as Helpful if it resolves your question. 🙂
Thanks,
Yogesh Bhatt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Ho Yogesh, thanks for the answer. Unfortunately it still doen't work, there must be something I do wrong...
here's the policy:
The result is aver 9000 items, but all failed. I Know for a fact it's not the case. I even verify some failed, and the Application ID is ok. (we use Tag governance version 1.10.0)