Scripting record producer submissions with catalog api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 10:39 AM
I'd like to add records to the HR Case table in a business rule using a record producer set to an hr_case table.
var cart = new Cart();
var catItemGR = new GlideRecord("sc_cat_item");
catItemGR.addQuery("name", "Contractor Update");
catItemGR.query();
if (catItemGR.next()) {
var item = cart.addItem(catItemGR.sys_id);
cart.setVariable(item, 'opened_by', lv_user_obj.sys_id);
cart.setVariable(item, 'Select_the_contractor_you_wish_to_upd', lv_user_obj.sys_id);
cart.setVariable(item, 'email', lv_current.variables.reqfor_email);
cart.setVariable(item, 'change_end', lv_current.variables.change_end);
cart.setVariable(item, 'contractor_name', lv_user_obj.name);
cart.setVariable(item, 'contractor_email', lv_user_obj.email);
cart.setVariable(item, 'contractor_department', lv_user_obj.department);
cart.setVariable(item, 'contractor_supervisor', lv_user_obj.manager);
cart.setVariable(item, 'contractor_location', lv_user_obj.location);
var rc = cart.placeOrder();
gs.log(rc.number + " should be an HRC number","AMP");
}
Even though the Contractor Update is a record producer for the hr_case table, the above code submits a sc_request record instead.
Does anyone know if placeOrder needs to be specified so that the record is submitted to the correct table?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 11:03 AM
Cart is used for specifically generating Request Items, executing their workflow, and wrapping them up in a Request. Its not what you want to use to create new types of HR work.
I'd take a deep look at the existing HR Case Management record producers to see how they generate the child tasks. Both the record producers and the HR Templates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 11:09 AM
I'm currently on a geneva instance and can't see the "Catalog & Templates" section in the side bar. Do I need a specific role?
I should also mention the hr_case work was done by someone else and appears as HR Catalog Legacy in the side bar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 11:31 AM
Try this...
<YOUR_INSTANCE_NAME>.service-now.com/cmdb_model_list.do?sysparm_query=cmdb_model_categoryLIKE764ff053d7332100bbc783e80e6103e9%5EORcmdb_model_categoryLIKEcc6ff053d7332100bbc783e80e6103ee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 11:37 AM
Hi Robert, do you mind describing what the above does/is supposed to do?
Thank you,