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:41 AM
Its a URL that takes you to the HR Case Templates on your instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 12:44 PM
I'm free tomorrow and dedicating all my hours to ServiceNow community.
If you'd like me to walk through this with you live, deconstruct where you're currently at, and put you on the right path forward, please let me know.
RDF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 08:04 AM
It looks like if we can't use placeOrder(), we'll need to write a script that properly runs the inserts so it adds both the hr_case record as well as the associated variables.
Is there a direct message function in servicenow community?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 08:56 PM
Hi Johnny,
Did you find a solution for your use case? can you please share.
Regards,
JS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 10:06 PM
Perhaps you might want to check out this code, that emulates the submission of a record producer:
https://community.servicenow.com/message/734832#734832
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022