Skip to content

Commit 1763eb7

Browse files
Create AddNoAuditAttributeToMultipleDictionaryEntries.js
Created A script to add the 'no-audit' attribute to multiple dictionary entries
1 parent 3e30e85 commit 1763eb7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
This script is used to add the [no_audit=true] attribute to multiple dictionary entries in bulk.
3+
Can be used for other attributes as well.
4+
NB: The attribut sys_id must be verified before the script execution!
5+
*/
6+
7+
var encodedQuery = '<insert encoded query here>'
8+
9+
//Verify this is in your instance before script execution
10+
var noAuitAttributeSysID = '96ea04dfeb321100d4360c505206fe7d';
11+
12+
var grSD = new GlideRecord('sys_dictionary');
13+
grSD.addEncodedQuery(encodedQuery);
14+
grSD.query();
15+
while (grSD.next()) {
16+
17+
18+
var grExistingAttribute = new GlideRecord('sys_schema_attribute_m2m');
19+
grExistingAttribute.addQuery('schema', grSD.getUniqueValue());
20+
grExistingAttribute.addQuery('attribute', noAuitAttributeSysID); //
21+
grExistingAttribute.query();
22+
23+
if(grExistingAttribute.hasNext()){
24+
grExistingAttribute.next();
25+
26+
if(grExistingAttribute.getValue('value')=='false'){
27+
grExistingAttribute.setValue('value', 'true');
28+
grExistingAttribute.update();
29+
}
30+
}else{
31+
32+
var grDicitionaryAttributeM2M = new GlideRecord('sys_schema_attribute_m2m');
33+
grDicitionaryAttributeM2M.initialize();
34+
grDicitionaryAttributeM2M.setValue('schema', grSD.getUniqueValue());
35+
grDicitionaryAttributeM2M.setValue('attribute', noAuitAttributeSysID)
36+
grDicitionaryAttributeM2M.setValue('value', 'true');
37+
grDicitionaryAttributeM2M.insert();
38+
}
39+
40+
}

0 commit comments

Comments
 (0)