Tag Governance Policy for checking the length of the value

SaiSindhuS
Tera Contributor

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.

@Ram Devanathan1 

1 REPLY 1

marcguegueniat
Kilo Sage

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,