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 

 

 

1 ACCEPTED SOLUTION

Santosh_Ksagar
Mega Sage
Mega Sage

Hi Carl,

 

try this:-

 

set Business Rule

when to run condition as ----->  u_item_status_choice -- changes to -- Shipped 

and in scipt--------> current.u_date_shipped_glide_date = gs.nowDateTime();

 

 

Please mark answer correct if it solves your problem.

 

Cheers

Santosh Kshirsagar

 

 

View solution in original post

3 REPLIES 3

Santosh_Ksagar
Mega Sage
Mega Sage

Hi Carl,

 

try this:-

 

set Business Rule

when to run condition as ----->  u_item_status_choice -- changes to -- Shipped 

and in scipt--------> current.u_date_shipped_glide_date = gs.nowDateTime();

 

 

Please mark answer correct if it solves your problem.

 

Cheers

Santosh Kshirsagar

 

 

carlh
Kilo Guru

thank you!!!  this works great.  the date format is funny but I can deal with it.  I appreciate your prompt reply!

Santosh_Ksagar
Mega Sage
Mega Sage

No Problem,

Actually today I dealt with the similar problem for date field validation for Record Producer variable set. I spend my half day figuring out solution for that still couldn't find out.