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.

Copy fields from Securkty Incident to Response Task

Community Alums
Not applicable

I have two tables: Security Incident and Response Tasks.

 

There are about 20 fields I want to copy down to the response task when created. What is the best way to relate the two to be able to add the fields to the response task?

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Community Alums 

 

I think the best way to create property and call that property in UI action, like we have on Incident table , copy incident.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Maddysunil
Kilo Sage

@Community Alums 

You can follow below approach:

  1. Create a Reference Field:

    • In the Response Tasks table, create a reference field that refers to the Security Incident table. This will establish a relationship between the two tables.
  2. Configure the Reference Field:

    • Configure the reference field to point to the Security Incident table. This can be done by setting the "Reference" field on the reference field configuration.
  3. Create Business Rule:

    • Create a business rule on the Response Tasks table that triggers when a new record is inserted.
    • In the business rule script, use the GlideRecord API to query the corresponding Security Incident record and copy the desired fields.

    Example Business Rule Script:

 

(function executeRule(current, previous /* , gs */) {
    if (current.operation() == 'insert') {
        var securityIncident = new GlideRecord('security_incident');
        if (securityIncident.get(current.security_incident)) {
            // Copy fields from Security Incident to Response Task
            current.field1 = securityIncident.field1;
            current.field2 = securityIncident.field2;
            // ... copy other fields as needed
        }
    }
})(current, previous);
​

 

Please mark my response correct/helpful, if it helps you!

@Community Alums 

If my response is useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

Thanks

AshishKM
Kilo Patron
Kilo Patron

Hi @Community Alums,

You can read the incident data and pass the values to response task in the same process which is creating this response task, this incident & response task must be related using some column on response task table(form).

 

-Thanks,

AshishKM 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution