How to automatically submit an item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 12:40 PM
Hi ServiceNow Community Developers,
I have the following requirement : There is a catalog item called 'Request Equipment Rotation' that I created, I did not add it to any category in order to prevent users from manually selecting it and start populating all the variables so they can submit it. This catalog item has a few variables (5 all together). The requirement is for this catalog item to be triggered by some field in the asset table. There is a field in asset form called 'rotation_disposition' and when a user populates this field and save this should trigger the automatic population and submission of the 'Request Equipment Rotation' catalog item. In other words the manual process of submitting a request for an item whereby you choose an item and then populate all the variables and hit the 'Order Now' button to submit your request should be automated for this particular item. The process of populating the variables and submitting the request should be done behind the scenes. Would you guys please advise if this kind of functionality is possible on the ServiceNow platform and if it is how would I go about implementing? Please advise.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 01:04 PM
I'd look at a business Rule that is triggered when your criteria is met.
Make that BR create a new item using this
http://wiki.servicenow.com/index.php?title=Service_Catalog_Script_API#gsc.tab=0
and take what ever values from the relevant record and add as a cartVariable.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 01:18 PM
Hi Julian,
Thanks for your response, it worked!
Do you know how do I mark this as the correct answer.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 01:21 PM
Thank you very Edwin and Julian.
Both you guys gave me the correct answer, this is greatly appreciated as I have never done this kind of functionality before.
I would like to mark this question as answered but I don't see the link to do so. Would appreciate the pointer to that.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 01:14 PM
Hello Johannes,
For this requirement you can create an after update/insert business rule in the asset table:
Table: Asset
Advanced = true
When = after
Check insert and check update
Filter condition = rotation_disposition is not empty
Script (Advanced tab):
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('Replace this text with the sys_id of the request item'); //Example e46305bdc0a8010a00645e608031eb0f
cart.setVariable(item, 'name of your variable', current.nameOfTheVariable); //Example cart.setVariable(item, 'requested_for', e46305bdc0a8010a00645e608031eb0f;
var rc = cart.placeOrder();
https://wiki.servicenow.com/index.php?title=Service_Catalog_Script_API#gsc.tab=0
Thank you.