Remove group from workflow approval group activity via script.

Vijay Baokar
Kilo Sage

Hi Folks,

 

I have written below BR to remove the group from group notification if its getting deactivated which is working perfect but how can i remove the same group from "workflow approval group activity" if this group is used for group approval. This BR is running on sys_user_group table with condition active changes to false.

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var Grp = current.getValue("sys_id");// Sys_id of deactivated group.
    var GRgrp = new GlideRecord('sysevent_email_action');
    GRgrp.addQuery('recipient_groups',Grp);
    GRgrp.query();
    while (GRgrp.next())
    {
        var watchlst = GRgrp.recipient_groups.toString();
        var newWatch = watchlst.replace(Grp, '');
        GRgrp.recipient_groups = newWatch;

        GRgrp.update();
    }

    //var wf = new GlideRecord('wf_activity');

})(current, previous);
2 ACCEPTED SOLUTIONS

Kieran Anson
Kilo Patron

Workflow activity variables are stored on the sys_variable_value. The 'value' will be the sys_id of the group

KieranAnson_0-1715857314658.png

KieranAnson_1-1715857325896.png

 

View solution in original post

its works with below code:

 

var wfgr = new GlideRecord('sys_variable_value');
    var myquery = "valueLIKE" + Grp;
    wfgr.addEncodedQuery(myquery);
    wfgr.query();

    while (wfgr.next()) {
        var watchlist = wfgr.value.toString();
        var newWatchlst = watchlist.replace(Grp, '');
        wfgr.value = newWatchlst;
        wfgr.update();
    }

View solution in original post

5 REPLIES 5

its works with below code:

 

var wfgr = new GlideRecord('sys_variable_value');
    var myquery = "valueLIKE" + Grp;
    wfgr.addEncodedQuery(myquery);
    wfgr.query();

    while (wfgr.next()) {
        var watchlist = wfgr.value.toString();
        var newWatchlst = watchlist.replace(Grp, '');
        wfgr.value = newWatchlst;
        wfgr.update();
    }