Update updated field with current date and time

nani8
Kilo Explorer

Hi Friends,

I am new to SNOW Development.I have one requirement regarding problem form.Below is the requirement:  

I have one problem record.In that there is one field called updated(date and time field).In that problem record there is one related list called Problem task(related to problem_task table).     If i create or update the problem task record,then the updated field in the parent record will get updated with current date and time.For this requirement i have created one business rule on table PROBLEM and when as AFTER UPDATE.I had written this code:  

var parent_problem = current.problem;

var parent_sys_updated_on= parent_problem.sys_updated_on;

if(current.problem_task==created ||current.problem_task==updated)

{  

current.problem_sys_updated_on=gs.nowDateTime();

}

 

I need assistance on this.Kindly please help friends.Waiting for your response...........

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Kumar,



What you need to do is to have a business rule on the Problem Task which will run everytime and have the script as something like:



var gr = new GlideRecord('problem');


gr.get(current.problem.sys_id);


gr.setForceUpdate(true);  


gr.update();  


View solution in original post

4 REPLIES 4

manikorada
ServiceNow Employee
ServiceNow Employee

Kumar,



What you need to do is to have a business rule on the Problem Task which will run everytime and have the script as something like:



var gr = new GlideRecord('problem');


gr.get(current.problem.sys_id);


gr.setForceUpdate(true);  


gr.update();  


Hi Manikanta.Thanks for your response.


So what i understand from your above code is no need of using glide date functions?


I have used above code.But its not working.Can you please suggest on this!!!!!!!


Thanks in Advance


manikorada
ServiceNow Employee
ServiceNow Employee

Kumar,



Can you send me the screenshot of your business rule?


Hi Mani kanta,


I have just modified the code by placing glide date function.It worked. Thank you very much for your time.See the modified code once:


var gr = new GlideRecord('problem');


gr.get(current.problem.sys_id);


gr.setForceUpdate(true);


current.problem_sys_updated_on=gs.nowDateTime();


gr.update();