Script to show Day,Week,Month,...

Script to show Day,Week,Month,...

We defined a custom filed and we want when a request submitted in Rule and Filed , run a script :
for example:
 If CREATEDDATE=today  Set in UDF: TODAY
 If CREATEDDATE>today  Set in UDF: YESTERDAY
.....
 If CREATEDDATE=thisyear  Set in UDF: THISYEAR



var x=$CS.getValue("CREATEDDATE");
 var currentDate = Now();

if (x>=currentDate) {
  
$CS.setValue("WorkOrder_Multi_Fields_UDF_CHAR4",["Today"]);
}

if (x>=Today) {
  
$CS.setValue("WorkOrder_Multi_Fields_UDF_CHAR4",["Yesterday"]);
}
if (x>=thisweek) {
  
$CS.setValue("WorkOrder_Multi_Fields_UDF_CHAR4",["This Week"]);
}

                  New to ADSelfService Plus?