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

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Can you add any log to see if the script is coming on the if condition of GlideRecord?

-Anurag

Sandeep Rajput
Tera Patron
Tera Patron

@Shaik22 Can you try the following and see if it works.

 

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

swathisarang98
Giga Sage

Hi @Shaik22 ,

 

In the below script is your addquery correct ? check the backend value of Manual, and try to put some log inside if and put current.u_control_owner in gs.info so that you will get to know what it is fetching..please share the logs screenshot 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

How to put log? and where should i put log?