Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

Klaus Schacht
Tera Contributor

Aparently it doesn't populate the fields from incident before pressing submit on the task, eventhough "Before" is chosen. I was expecting it to populate the desired fields upon creation of the task. This is a Nice To Have feature but for now this procedure is acceptable. Thanks for all your replies 

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

Thanks I will definetly try it out 😉