Tag Governance Policy for checking the length of the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 09:43 AM
Hi Team,
Is there a Tag Governance Policy for checking the length of the value. The use case is to check if a tag key value is 5 characters.
eg; Tag key is abc. abc value must needs to be 5 numerical characters. Ifabc is less than 5 characters , then need to be considered as non-compliant
How can we do this, Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 09:02 AM
Hello,
There is no OOB Tag policy Type to do that.
You will have to create your own scripted policy type into the sn_itom_tag_policy_type table.
I think a script like this should do the job:
//warning: this code was not tested
var tagsToCheck = policy.expected_tag_keys.split(',');
var badTags = [];
var expectedLength = 5;
var arrayUtil = new global.ArrayUtil();
while (ciTags.next()) {
var key = ciTags.getValue('key') + '';
var tagIndex = arrayUtil.indexOf(requiredTags, key);
if (tagIndex >= 0) {
if (key.length != expectedLength) {
badTags.push(key);
}
}
}
complianceState = (badTags.length === 0);
if (!complianceState) {
complianceDescription = 'Bad length for tag(s): ' + badTags.join(',');
}
Then create a Tag Policy with this new Tag Policy Type and put the tags to be checked into the "Expected Tag Keys" field.
Regards,