Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update assigned to field

Shaik22
Tera Expert

Hi,

 

Control owner field is on Control(sn_compliance_control) table. Assigned To and Evidence Execution fields on Control Executor(sn_audit_control_compliance) table. If we select control owner, assigned to have update, Only for Evidence Execution field is Manual. Wrote a script but it is not updating the assigned to field. Any help!

 

Table : control[sn_compliance_control]

After(Insert,Update) business rule

Condition : Control owner changes

Script: 

var controlGR = new GlideRecord('sn_audit_control_execution');
    controlGR.addQuery('u_evidence_execution', 'Manual');
    controlGR.query();
    if (controlGR.next()) {
        controlGR.assigned_to = current.u_control_owner;
        controlGR.update();
    }

 

 

 

11 REPLIES 11

like below

gs.log('start of script');
var controlGR = new GlideRecord('sn_audit_control_execution');
    controlGR.addQuery('u_evidence_execution', 'Manual');
    controlGR.query();
    if (controlGR.next()) {
gs.log('this was executed');
        controlGR.assigned_to = current.u_control_owner;
        controlGR.update();
    }
 
-Anurag

  var controlGR = new GlideRecord('sn_audit_control_execution');
    controlGR.addQuery('u_evidence_execution', 'Manual');
    controlGR.query();
    if (controlGR.next()) {
        gs.info('this was executed');
        //controlGR.assigned_to = current.u_control_executor;
        controlGR.assigned_to.getDisplayValue() = current.getValue('u_control_executor');
        gs.info('assigned to updated:'+ controlGR.assigned_to);
       controlGR.update();
    }
getting below

Shaik22_0-1725359349487.png

 

Run this

 var controlGR = new GlideRecord('sn_audit_control_execution');
    controlGR.addQuery('u_evidence_execution', 'Manual');
    controlGR.query();
    if (controlGR.next()) {
        gs.info('this was executed');
        //controlGR.assigned_to = current.u_control_executor;
        controlGR.assigned_to = current.getValue('u_control_executor');
        gs.info('assigned to updated:'+ controlGR.assigned_to);
       controlGR.update();
    }

 

in the log search by message contains 'this was executed'

-Anurag

getting below. when i execute above code.

Shaik22_0-1725359955168.png

 

🙂 you are not doing what i suggested 

anyway, is the field updated? Check the record history

is this BR before or after?

-Anurag