How to get populate "incident" creation date on "incident_task" one date/time field.

sinu2
Tera Expert

HI all,

I am getting struck with populating "incident" cretion date/time in to another table "incident_task" 

for this i have written after BR .Please find the below script

 

@I have checked that gs.log('incident creation date:' +current.sys_created_on); in this log current.sys_created_on is not comming on logs

(function executeRule(current, previous /*null when async*/) {

current.sys_created_on = current.u_original_date;
gs.log('incident creation date:' +current.sys_created_on);
var inc_dte = new GlideRecord('incident_task');
inc_dte.addQuery('incident',current.sys_id);
inc_dte.query();
gs.log('incident records match:' +current.sys_id);
if(inc_dte.next()){

current.u_original_date = inc_dte.u_original_date;
gs.log('incident original date:' +inc_dte.u_original_date);
inc_dte.update();

}

})(current, previous);

 

Can anyone help on this

9 REPLIES 9

sachin_namjoshi
Kilo Patron
Kilo Patron

Please make sure that your BR is AFTER and NOT before.

 

Regards,

Sachin

Luuk Vonk
Tera Guru

Please share your BR settings. On my developer instance your script was working.

Table: incident
Insert: True
Update:true(this won't be necessary)
When: After

 

Hi This is my conditions in my BR

 

find_real_file.png

Varsha21
Giga Guru
Hi First check your if condition is true or not? Then inc_dte.query(); inc_dte.gwtRowCount();//log it Why because it is happening when you create incident as soon as it is not creating task Right. Then how it will get task record to update field and since it is not giving any value in log. Varsha