Field is not updating

Shaik22
Tera Expert

Hi,

'Control Executor'(List Field- user table) field is on Control(sys_compliance_control) table. 'Assigned To' and 'Evidence Execution' fields on Control execution(sn_audit_control_execution) table. condition : Evidence execution is Manual and for example assigned to is Brad, Jay i want to populate on Control Executor field. If any user updates the Assigned To field i want to update control executor field. Wrote a script but it is not working. Any help!

 

Application : GRC: Policy and Compliance Management

Business rule : After - Insert,Update

Table : sn_audit_control_execution

Script: 

(function executeRule(current, previous /*null when async*/ ) {
if (current.assigned_to.changes()) {
if (current.u_evidence_execution == 'Manual') {
var controlGR = new GlideRecord('sys_compliance_control');
 if (controlGR.get(current.control.number)) {
 var assignedUsers = [];
                var assignedToUsers = current.assigned_to.toString().split(',');
                for (var i = 0; i < assignedToUsers.length; i++) {
                    assignedUsers.push(assignedToUsers[i].trim());
                }
                controlGR.u_control_executor.toString() = assignedUsers.join(',');
                controlGR.update();
            }
        }
    }
})(current, previous);

 

1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

@Shaik22 Can you replace the following line 

controlGR.u_control_executor.toString() = assignedUsers.join(',');

with

controlGR.u_control_executor= assignedUsers.join(',');

In case if this doesn't work, try executing this script in a background script (by replacing current with a glide record) and check if it works fine with a sample record. Fix script if it doesn't work with a sample record in background script.