auto populate incident field on incident task table

pvv1045330
Tera Contributor

Hi All,

 

I have a requirement to populate field values from incident to incident task,

 

In Incident form i am having (business_service=abc,  service_offering=wer, cmdb_ci=cde, short_description=test)

these fields i want to populate on incident task while creating new incident task from incident.

 

For  this requirement I'm using below code it's populated  all values except 'service_offering' filed value .

Can any one help me on that how can I auto populate all values

Script Include:

taskinfo: function(){
        var info = this.getParameter('inc_id');
        var gr = new GlideRecord("incident");
        gr.get(info);
        var ITbs = gr.getValue('business_service');
        var ITso = gr.getValue('service_offering');
       var ITsd = gr.getValue('short_description');
        var response = {};
        response.ITbs = ITbs;
        response.ITso = ITso;     
        response.ITsd = ITsd;
        return JSON.stringify(response);
    },
 
Client script: 
var incident_sys_id = g_form.getValue('incident') ;
    if(incident_id != ''){
        var ga = new GlideAjax('name');
        ga.addParam('sysparm_name'"taskinfo");
        ga.addParam('inc_id', incident_id); 
        ga.getXMLAnswer(function(answer){ 
            var response = JSON.parse(answer);
            g_form.setValue('business_service', response.ITbs) ;
            g_form.setValue('service_offering', response.ITso) ;
 
can you correct me what I miss on script for populated all value.
 
Thanks,
    
1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@pvv1045330 The script appears to be correct. However, on the incident_task from there is a reference qualifier defined on the Service offering field which only let select those service offering where the parent is value populated on the Business Service field.

Screenshot 2023-10-05 at 12.04.54 AM.png

In your script, please make sure to populate only those Service offering which are children of Business Service populated on the Service field.

View solution in original post

9 REPLIES 9

Chandresh Tiwa2
Mega Guru

Hi,

 

did you check if your service offering has the parent as the business service which you are selecting. Because in baseline version of ServiceNow task table has reference qualifier on service offering field ( javascript:'parent='+current.business_service;). Pass only that service offering and business service which are related. 

Anand Kumar P
Giga Patron
Giga Patron

Hi @pvv1045330 ,

You script is correct please check service offering you are fetching is not empty for that record. 

AnandKumarP_0-1696444765956.png

Thanks,

Anand

Sandeep Rajput
Tera Patron
Tera Patron

@pvv1045330 The script appears to be correct. However, on the incident_task from there is a reference qualifier defined on the Service offering field which only let select those service offering where the parent is value populated on the Business Service field.

Screenshot 2023-10-05 at 12.04.54 AM.png

In your script, please make sure to populate only those Service offering which are children of Business Service populated on the Service field.

Hi Sandeep,

Thanks for the response,
If service offering have contain one value it will populated, but it's contain multiple values not value got cleared.

 

Please help me how to resolve the issue.