Set requested item due date = user entered date variable

Hernan3
Kilo Contributor

Is there a way we can set the Due Date on the requested item to be equal to a date variable the user is entering? From what I read, the map to field feature is only available for record producers and it's currently not available for catalog items. Any suggestions would be appreciated.

1 ACCEPTED SOLUTION

ggiri1
ServiceNow Employee
ServiceNow Employee

Hi Hernan,



Create a business rule on sc_req_item table with order 1000 and before. Add condition item as your catalog item name.


write a script as below:



if(current.variables.<<date_variable>>)


  {


  current.due_date = current.variables.<<date_variable>>;


  }



Thanks,


Giri Guntoju


View solution in original post

8 REPLIES 8

Alikutty A
Tera Sage

Hi Hernan,



You need to write a before insert business rule on the requested item table to achieve this requirement.



The script would have this single line



current.due_date = current.variables.due_date_variable;   //replace with your variable name



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Were you able to check this out?



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Not yet, I will give this a try in a few hours and get back to you. Thank you for your feedback.


Hello,

 

The business rule I am using is below: 

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

// Add your code here
if(current.variables.effective_date.getDisplayValue)

{

current.due_date = current.variables.effective_date.getDisplayValue();

}


})(current, previous);

The variable is a date variable because we would like to avoid using the date/time variable for this catalog item. Unfortunately, because of this, the due date is being set to something like this: 06-18-2018 00:00:00. In my workflow I am using a timer that waits for the due date and it is preventing the timer from working properly. Would you be able to help me to edit the business rule so that it adds time to the due date so it doesn't show 00:00:00?