Copy the few fields from Problem record to Problem Task

cp10
Tera Contributor

Hi, I have requirement to copy the few fields from Problem (under Analysis information tab) record to Problem Task(under Analysis information tab). whenever the problem task is created the data will be copy to the problem task. I tried below BR but its not working for me. Please help me on this issue fixed.

 
BR:   var probTask = new GlideRecord('problem_task');
         probTask.addQuery('problem',current.sys_id);
         probTask.query();
         if(probTask.next()) {
         probTask.workaround = current.workaround;
         probTask.fix_notes = current.fix_notes;
         probTask.cause_notes = current.cause_notes;
         probTask.update();
    }
})(current, previous);
3 REPLIES 3

anvesh_v
Giga Guru

Could you please elaborate on which table you are writing the business rule if you are writing on insertion of problem task no need of GlideRecord you can update based on current object only 

 

current.short_descrption = current.problem.short_descrption

if you are writing on problem table

  var probTask = new GlideRecord('problem_task');
         probTask.addQuery('problem',current.sys_id);  // This will query all the PTASKS NOT specific modify the query 
         probTask.query();
         if(probTask.next()) {
         probTask.workaround = current.workaround;
         probTask.fix_notes = current.fix_notes;
         probTask.cause_notes = current.cause_notes;
         probTask.update();
    }




cp10
Tera Contributor

Hi @anvesh_v , Thanks for the reply.. I am writing the BR on 'Problem' table. could you please let me know what changes needs to be updated on Business rule.

 

Thanks.

Update the conditions on the respective BR  and use the same script as above if PTASK is already created on system 

 var probTask = new GlideRecord('problem_task');
         probTask.addQuery('problem',current.sys_id);  // This will query all the PTASKS NOT specific modify the query 
         probTask.query();
         if(probTask.next()) {
         probTask.workaround = current.workaround;
         probTask.fix_notes = current.fix_notes;
         probTask.cause_notes = current.cause_notes;
         probTask.update();
    }