We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Need 'script include' or 'Business Rule' to transfer TPRM IRQ question ref value to the TPRM DD

LVPhanee
Tera Contributor

Need 'script include' or 'Business Rule' to transfer TPRM IRQ question reference value to the TPRM Due Diligence form

 

Requirement : 

As part of Client requirement we have added a new Reference field in the TPRM- Third-party Risk Management application scope, that reference value needs to be auto populated in the Due diligence TPRM- 'Third-party Risk Due Diligence'  application scope. 

 

conditions:

1. IRQ questions values can be selected/changed until the questions are submitted, once the questions are submitted its value can't be changed. 

2. The above IRQ selected value should be auto populated to DD reference field. 

3. TPRM Manager can change the Due Diligence Newly added reference value as per his convenience ( the value which is auto populated)

4. This reference field  Third-party Risk Due Diligence'  application scope value should have privilege for TPRM Manager to be changed any number of time in the Due Diligence work flow.

 

Can you please suggest which is best 'Script include' or 'Business Rule'. 
And give some sample code for this requirement. 

3 REPLIES 3

vaishali231
Tera Guru

Hey @LVPhanee 

 

In this scenario, a Business Rule would be the better approach instead of a Script Include.

Since the requirement is to auto-populate the IRQ reference field into the Due Diligence record once the IRQ questions are submitted, this is a record-to-record synchronization use case. An After Update Business Rule on the IRQ table is sufficient.

Trigger Condition:

Run After Update

Execute only when Status changes to Submitted

This ensures:

IRQ values can be changed until submission.

Once submitted, the selected reference value is copied to Due Diligence.

TPRM Manager can still modify the Due Diligence reference field later via proper ACL configuration.

 Script :

(function executeRule(current, previous) {

// Run only when status changes to Submitted
if (current.state == 'submitted' && previous.state != 'submitted') {

if (!current.u_reference_field)
return;

var ddGR = new GlideRecord('sn_tprm_due_diligence'); // your table
ddGR.addQuery('u_irq_reference', current.sys_id); //  relationship field
ddGR.query();

if (ddGR.next()) {
if (!ddGR.u_dd_reference_field) { // populate only if empty
ddGR.u_dd_reference_field = current.u_reference_field;
ddGR.update();
}
}
}

})(current, previous);


Additionally:

Ensure cross-scope access is allowed between the two application scopes.

Provide write ACL to tprm_manager role so they can update the Due Diligence reference field as required.

*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

BBijag02
Kilo Sage

Hi @LVPhanee 

Niether Script include or BR (unless it is before insert), but in my opinion a flow. It is easy to maintain, especially for non developer folks.

Also ServiceNow recommended best practice is to create a flow.

 

Best regards,

Bhavesh

 

vaishali231
Tera Guru

hey @LVPhanee 

Hope you are doing well.

Did my previous reply answer your question?

If it was helpful, please mark it as correct ✓ and close the thread 🔒. This will help other readers find the solution more easily.

Regards,
Vaishali Singh