Need a script to set a glide date field.

carlh
Kilo Guru

Hi All,  I am working on updating our RITM form to add in a ship date.

 

I have a choice field called "Item Status" (u_item_status_choice).  The default value is "NEW"  There are 2 other status's...."Awaiting Configuration" and "Shipped"  (The Label and Value is exactly the same)

 

I also added a field called "Date Shipped" (u_date_shipped_glide_date)

What I am looking to do is set the value of the "Date Shipped" field to "now" when the Item status changes to "Shipped".

I tried to make a before business rule on update but it's not working for me.

(function executeRule(current, previous /*null when async*/) {
 
 var now = new GlideDateTime();
 if(current.u_item_status_choice == Shipped && previous.u_item_status_choice == New){
 
  current.u_date_shipped_glide_date = now;
 } 
})(current, previous);

 

Could someone help me correct this script.

 

We don't use the RITM and Request as intended.  This is just a solution for me to be able to show what I shipped today on a report. 

The report would show all RITM's where Date Shipped = today or last 7 days, or this month or this year, etc.

 

Thanks in advance for any help.

 

Regards,

 

Carl