Copy fields from "Problem Ticket" to "Problem Task Ticket"

kam_steven_
Kilo Contributor

I have created a client script to copy fields from "Problem Ticket" to "Problem Task Ticket", it didn't work. Can someone guide me through?

Table=Problem

Type=onLoad

function onLoad() {
    //Type appropriate comment here, and begin script below
if(g_form.isNewRecord() && g_form.getValue('parent') != ''){

var prb = g_form.getReference('parent', setFields);

}

function setFields(prb){

g_form.setValue('assignment_group',prb.assignment_group);
g_form.setValue('priority',prb.priority);

}  
}

Thanks.

Steven

1 ACCEPTED SOLUTION

And then do javascript:parent.priority for an override on the priority.


View solution in original post

29 REPLIES 29

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Kam,



This will not work. You have to query the problem_task table to update the record. However I would recommend you to create a business rule(after insert update checkbox to true) on problem table.


Here is the script. Please modify it as per your req.


updateRec();


function updateRec()


{


  var probTask = new GlideRecord('problem_task');


  probTask.addQuery('problem', current.sys_id); //query all problem tasks


  probTask.query();


  while(probTask.next())


  {


  probTask.assignment_group = current.assignment_group;


  probTask.priority = current.priority;


  probTask.update();


  }


}


It's not working ... Am I doing wrong?



find_real_file.png


Mike Allen
Mega Sage

You can do an display business rule that says:



current.assignment_group = current.parent.assignment_group;


current.priority = current.parent.priority;


find_real_file.png



It's not working. Am I making mistakes?