ALternative for "run script" in flow designer

Hafsa1
Mega Sage

I need to run a script having glide record to 1-2 tables and then update records in both tables.

Earlier in workflow editor, we used RUN script to execute it. Now we have to move to flow designer but I'm not getting any action for simply running script. Anyone knows what to use?

3 REPLIES 3

Brad Warman
Giga Sage

Hi @Hafsa1,

 

There is an action called update multiple records that can be used to find the records you need using a filter and then update them as required. If that doesn't suit, there is also an action called look up records where you can find records based on a filter which are then stored in a data object that can used in a loop or update record action too.

 

If these options don't suffice and you have to run a script, you can create a new action and include a script step in it to handle the updates and output your desired data. The script action you create will become available in the flow editor as a custom action once you publish it.

 

BradWarman_0-1723785649806.png

 

BradWarman_1-1723785675756.png

 

 

Cheers,

 

Brad

Hafsa1
Mega Sage

i have below script to run on hr task table

 

var grp = current.groups.toString(); //Group to execute action against
    var grps = grp.split(',');
    var subject = current.opened_by; //Get User to execute action against
    var requestor = current.opened_for; //Get Requestor
    var grpMgr;
    var group = '';
    for (var i = 0; i < grps.length; i++) {
        grpMgr = grps[i].manager; //Get the Groups Manager
        var grMbr = new GlideRecord('sys_user_grmember'); //Initiate Glide against Group membership table
        //Add Group membership  
        grMbr.initialize();
        grMbr.user = subject;
        grMbr.group = grps[i];
        grMbr.insert();
        group += "," + grMbr.group.getDisplayValue();
    }
    //Send the notification to the Requestor and Group Manager that the User has been removed from the Group
    gs.eventQueue('sn_hr_core.group_member_added', fd_data.trigger.current, grpMgr, requestor);
    current.work_notes = subject.getDisplayValue() + " successfully added to " + group; //Update Work Note with confirmation
    current.state = 3;
    current.active = false;
    current.update();

brother just paste this code in your custom action, script step