- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 10:41 PM
Hi,
I have a requirement to write a scheduled job which runs every weekday.
I have developed a catalog item which looks as follows:
When I fill this catalog item, it automatically creates a Request, RITM and Catalog Task.
So now, this catalog item should be ordered automatically every weekday so that it finally creates a Request, RITM and Catalog Task.
I am very new to Servicenow and unable to think of how to solve this. Please help.
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:33 PM
Run:onDemand
conditional: true
condtition:
function checkWeekdays() {
var now = new Date();
var day = now.getDay();
var result = false;
if(day != 0 && day != 6) {
result = true;
}
return result;
}
checkWeekdays();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:12 PM
Hi Prudhvi
Write below script in the scheduled job and update that according to the comment.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); // Put the sys_id of the catalog item that you want to raise the request
cart.setVariable(item, 'os', 'Linux Red Hat'); // set the other variables of your catalog item accordingly
var rc = cart.placeOrder();
gs.info(rc.number);
See the below link for the details
http://wiki.servicenow.com/index.php?title=Service_Catalog_Script_API#gsc.tab=0
-Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:16 PM
Thanks for the reply Harsh.
I just have one doubt with the line - cart.setVariable(item, 'os', 'Linux Red Hat'); // set the other variables of your catalog item accordingly
In this line, 'os' is the name of the variable in the catalog item and 'Linux Red Hat' is the value of it. Am I right? Please let me know.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:18 PM
Yes, you are correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2017 11:29 PM