From 72f580ebd2fd120f9f5400bdfef16bbf33fb9267 Mon Sep 17 00:00:00 2001 From: MartinStoyanoff <37848972+MartinStoyanoff@users.noreply.github.com> Date: Fri, 7 Oct 2022 13:36:03 +0300 Subject: [PATCH 1/3] Create README.md --- .../Randomly distrubite events between custom queues/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Business Rules/Randomly distrubite events between custom queues/README.md diff --git a/Business Rules/Randomly distrubite events between custom queues/README.md b/Business Rules/Randomly distrubite events between custom queues/README.md new file mode 100644 index 0000000000..314e4503d2 --- /dev/null +++ b/Business Rules/Randomly distrubite events between custom queues/README.md @@ -0,0 +1 @@ +This business rule helps generate multiple events, which are randomly and almost perfetly even distributed by a specified number of custom queues. From 7cfb10e0ac327a5b6b71bb8bb110e7bef4ad2e2d Mon Sep 17 00:00:00 2001 From: MartinStoyanoff <37848972+MartinStoyanoff@users.noreply.github.com> Date: Fri, 7 Oct 2022 13:39:32 +0300 Subject: [PATCH 2/3] Create DistrubuteEvents.js --- .../DistrubuteEvents.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Business Rules/Randomly distrubite events between custom queues/DistrubuteEvents.js diff --git a/Business Rules/Randomly distrubite events between custom queues/DistrubuteEvents.js b/Business Rules/Randomly distrubite events between custom queues/DistrubuteEvents.js new file mode 100644 index 0000000000..c4c6f86589 --- /dev/null +++ b/Business Rules/Randomly distrubite events between custom queues/DistrubuteEvents.js @@ -0,0 +1,16 @@ +(function executeRule(current, previous /*null when async*/ ) { + + //define the queues array + var event_queues = ['custom_queue_1', 'custom_queue_2','custom_queue_3','custom_queue_4'] + + //initialize glide record and do some filtering if necessary + var grSomeContainer = new GlideRecord('container_table'); + grSomeContainer.addQuery('column', 'value'); //do some filtering if necessary + grSomeContainer.query(); + + //for each one of the elements log an event with 5th parameter distributing it a specific queue from the array above + while (grSomeContainer.next()) { + gs.eventQueue('scope.event_name', grSomeContainer, null, null, event_queues[Math.floor(Math.random()*event_queues.length)]); + } + +})(current, previous); From 1763eb74f5fd3ece9b541d070a4ad9e27ff30ce7 Mon Sep 17 00:00:00 2001 From: MartinStoyanoff <37848972+MartinStoyanoff@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:47:32 +0300 Subject: [PATCH 3/3] Create AddNoAuditAttributeToMultipleDictionaryEntries.js Created A script to add the 'no-audit' attribute to multiple dictionary entries --- ...ditAttributeToMultipleDictionaryEntries.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Background Scripts/Add No Audit Attribute To Multiple Dictionary Entries/AddNoAuditAttributeToMultipleDictionaryEntries.js diff --git a/Background Scripts/Add No Audit Attribute To Multiple Dictionary Entries/AddNoAuditAttributeToMultipleDictionaryEntries.js b/Background Scripts/Add No Audit Attribute To Multiple Dictionary Entries/AddNoAuditAttributeToMultipleDictionaryEntries.js new file mode 100644 index 0000000000..f31e98b724 --- /dev/null +++ b/Background Scripts/Add No Audit Attribute To Multiple Dictionary Entries/AddNoAuditAttributeToMultipleDictionaryEntries.js @@ -0,0 +1,40 @@ +/* +This script is used to add the [no_audit=true] attribute to multiple dictionary entries in bulk. +Can be used for other attributes as well. +NB: The attribut sys_id must be verified before the script execution! +*/ + +var encodedQuery = '' + +//Verify this is in your instance before script execution +var noAuitAttributeSysID = '96ea04dfeb321100d4360c505206fe7d'; + +var grSD = new GlideRecord('sys_dictionary'); +grSD.addEncodedQuery(encodedQuery); +grSD.query(); +while (grSD.next()) { + + + var grExistingAttribute = new GlideRecord('sys_schema_attribute_m2m'); + grExistingAttribute.addQuery('schema', grSD.getUniqueValue()); + grExistingAttribute.addQuery('attribute', noAuitAttributeSysID); // + grExistingAttribute.query(); + + if(grExistingAttribute.hasNext()){ + grExistingAttribute.next(); + + if(grExistingAttribute.getValue('value')=='false'){ + grExistingAttribute.setValue('value', 'true'); + grExistingAttribute.update(); + } + }else{ + + var grDicitionaryAttributeM2M = new GlideRecord('sys_schema_attribute_m2m'); + grDicitionaryAttributeM2M.initialize(); + grDicitionaryAttributeM2M.setValue('schema', grSD.getUniqueValue()); + grDicitionaryAttributeM2M.setValue('attribute', noAuitAttributeSysID) + grDicitionaryAttributeM2M.setValue('value', 'true'); + grDicitionaryAttributeM2M.insert(); + } + +}