Flow Designer issue

Hafsa1
Mega Sage

I have below script to run on hr task table everytime task is updated, can anyone tell me how to add this in flow designer? Earlier this code was in workflow editor.

 

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();
6 REPLIES 6

Hafsa1
Mega Sage

when running is manually as system admin it is working. but when raised via non-admin user it is giving error. ALthough I have set property to run as system user.

you need to have the flow set to run as system user. Because it is creating and updating records, it needs appropriate permissions. The user submitting the request probably does not have sufficient access.