- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 06:33 AM
Hello @everyone. Good morning. I need some help reviewing the business rule below and give me advise to correct the issue of the RITM not created and not added to an existing current REQ. I appreciate the help.
------------------
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 07:27 AM
Just sharing the code that I finally was able to make to work just in case it can be useful for others
--------------------
--------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:17 AM
Hello @Bert_c1 . I was working on the code and modified it further as indicated below. on the update to the REQ, I am working to add another RITM record to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:35 AM
@Bert_c1 . I modified further modification with your inputs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:48 AM
@Bert_c1 . It still did not create the new RITM and the REQ updated even though the logs indicated it pass through key steps such as
Line 35 <SP_SPNT_SN_INT_ManualConfigRITM>-Parent REQ returned 1 records
Line 37 <SP_SPNT_SN_INT_ManualConfigRITM>-Parent REQ Insert
Business rule Line 59 <SP_SPNT_SN_INT_ManualConfigRITM>
RITM created successfully. RITM sys_id <SP_SPNT_SN_INT_ManualConfigRITM: 8053818edbffb300e90690b3db9619c4
Updated code below.
-------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 10:17 AM - edited 05-14-2024 10:19 AM
I now see you changed code to reference sc_cat_item table, when you want to create a record in the sc_req_item table. Proper code for that follows.
// Create a new RITM record
var ritmGr = new GlideRecord('sc_cat_item');
ritmGr.name = "Manual Configuration: " + current.variables.u_access_action
+ "For " + current.variables.u_access_name;
ritmGr.description = "Request Item related to " + current.number
+ "For " + current.variables.u_access_name;
ritmGr.group = accessTableGr.u_assign_group.toString();
// Add the RITM to the current active REQ
var reqRecord = new GlideRecord('sc_request');
reqRecord.addQuery('sys_id', current.request.sys_id);
reqRecord.query();
if (reqRecord.next())
{
gs.info("Line 35 <SP_SPNT_SN_INT_ManualConfigRITM>-Parent REQ returned " + reqRecord.getRowCount() + " records");
ritmGr.request = reqRecord.sys_id;
// no need to update the sc_request table, but need to set sc_req_item.request to request's sys_id
// recRecord.update(catItemGr.sys_id);
gs.info("Line 37 <SP_SPNT_SN_INT_ManualConfigRITM>-Parent REQ Insert");
}
// now create the sc_req_item record
var recInsertResult = ritmGr.insert();
gs.info("After Line 37 <SP_SPNT_SN_INT_ManualConfigRITM>-REQ Item Insert, result = " + recInsertResult);
use of 'current.request.sys_id' is suspect without knowing what table the BR is defined on. And how the 'request' field is defined. If a reference to the sc_request table, then that line should be:
reqRecord.addQuery('sys_id', current.request);
You first querried sys_request based on the 'number' field. good luck, very confusing on what your goal is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 11:42 AM
@Bert_c1 . Just curious question. Do I have to use cartjs to create a new RITM?