How to get all RITMs(Order Guide) description in Request Description field
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 06:16 PM - edited 12-20-2023 07:06 PM
I have requirement where I need to populate all the RITMs description in Request Description field
For example: If 3 RITMs are there for 1 request. Then description of all the Ritms should be populated in request description.
Business Rule :
table :Sc_request
Condition: After Insert
(function executeRule(current, previous /*null when async*/ ) {
var dateTime = new GlideDateTime();
dateTime.addSeconds(5);
gs.eventQueueScheduled('event_name', current, '', '', dateTime);
})(current, previous);
Script Action:
var req = new GlideRecord('sc_req_item');
req.addQuery('request', current.sys_id);
req.query();
while (req.next()) {
req.getRowCount();
if(req.getRowCount() == 1){
current.description = req.number + ": " + req.description;
}
else{
current.description = "Multiple RITMs are as follows: " + '\n' + req.number;
}
}
current.update();
This is not working as expected. Please help
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 11:13 PM
Hi @Rakesh11
You can achieve this via a before insert Business rule on sc_request table. Below are the snips and code for your reference :
(function executeRule(current, previous /*null when async*/) {
var reqDescription = "Multiple RITMs are as follows: " + '\n';
var req = new GlideRecord('sc_req_item');
req.addQuery('request', current.sys_id);
req.query();
while (req.next()) {
req.getRowCount();
if(req.getRowCount() == 1){
reqDescription += req.number + ':' + req.description;
}
else{
reqDescription += req.number + ':' + req.description + '\n' ;
}
}
current.description = reqDescription ;
})(current, previous);
Output :
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.