Copy fields from incident to incident task not working

Klaus Schacht
Tera Contributor

I have been trying to set up a Business Rule so when I create a Incindent Task from an incident it will copy desired fields to the task. Been using this Solved: copy fields from incident to incident task - ServiceNow Community . But apparently I cant seem to get it to work. Is there something I am missing? Have attached my Business rule. Hopefully someone can see what I am missing.

1 ACCEPTED SOLUTION

Hi @Klaus Schacht ,

Thanks for marking my response as helpful

if your issue is resolve could you please accept it as a solution and close the thread.

 

if you want to populate the info before submission( onload of the form) you can create a onload client script and client callable script include

 

Script include

ChaitanyaILCR_0-1751105920509.png

script 

var IncidentDetails = Class.create();
IncidentDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getIncidentDetails: function() {
        var incidentSysId = this.getParameter('sysparm_incidentSysId');
        var result = {};

        if (!incidentSysId) {
            return JSON.stringify(result);
        }

        var incident = new GlideRecord('incident');
        if (incident.get(incidentSysId)) {
            result.short_description = incident.getValue('short_description');
            result.assignment_group = incident.getValue('assignment_group');
        }

        return JSON.stringify(result);
    },
    type: 'IncidentDetails'
});

 

onLoad client script

ChaitanyaILCR_1-1751105982347.png

script

function onLoad() {
    var incidentSysid = g_form.getValue('incident');
    if (g_form.isNewRecord() && incidentSysid) {
        var ga = new GlideAjax('IncidentDetails');
        ga.addParam('sysparm_name', 'getIncidentDetails');
        ga.addParam('sysparm_incidentSysId', incidentSysid);
        ga.getXMLAnswer(function(response) {
            var data = JSON.parse(response);
            g_form.setValue('short_description', data.short_description);
            g_form.setValue('assignment_group', data.assignment_group);

        });
    }
}

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

7 REPLIES 7

dbook
Kilo Sage

At first glance this look correct. 

 

What is the exact issue? 

Does the Incident Task actually have a reference to an Incident? 

If yes, is the short description and assignment group populated in the linked Incident? 

When i create the Task it it doesn't populate the desired fields. They are both populated in the incident

Ankur Bawiskar
Tera Patron
Tera Patron

@Klaus Schacht 

it should work fine if your incident task gets created and has incident field populated.

If you are using parent field then use that instead of incident field

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Chaitanya ILCR
Kilo Patron

Hi @Klaus Schacht ,

 

are you using incident field or parent field for linking incident task to the incident?

 

if it's using parent field for linking update you BR condition and values with parent instead of incident

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya