Business Rule help for Request and Request Item short description and description

Gemma4
Mega Sage
Hi everyone,
I have a requirement to set the request and request item short description and description for the order guide I created. 
While doing this, I need to ensure the existing catalog item short description and description are not impacted. 
 
Below is a summary of the business rules created and what the requirements should be: 
 
New Requirements: 
 
- Request Short description should be variable request_name if catalog item is Project Management Request Catalog
 
2- Request Item Short description should be variable request_name if catalog item is Project Management Request Catalog
 
3- Request description should be catalog item name if catalog item is Project Management Request Catalog
 
4- Request Item description should be catalog item name- if catalog item is Project Management Request Catalog
 
 
RESULTS 
 
The Request is not displaying correctly. 
The description is empty and should be the catalog item name Project Management Request Catalog, same as Request item. 
In addition, the request short description is displaying Project Management Request Catalog - Requested For : undefined. 
 
The good news is short description and description on the Request Item for Project Management is correct and everything on the Request and Request item for L&D is working correctly.
Thank you in advance for any feedback you can provide to direct me to a resolution!
 
Original Business Rule 
- This business rule is impacting the new business rule. 
When this is marked inactive my new business rule works, however the catalog item for L&D short description and description is then impacted. 
I commented out a line to help exclude Project Management Request but had no luck
Table sc_request
When to run before , insert update selected
filter: short description is empty string
description is empty
 
 
 (function executeRule(current, previous /*null when async*/) {
 
// Add your code here code wrotten for request for
 
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', current.sys_id);
grRITM.query();
while (grRITM.next()) {
if(!JSUtil.nil(grRITM.cat_item.name) && grRITM.cat_item.name!='Project Management Request') {
 
//if (!JSUtil.nil(grRITM.cat_item.name)) {
current.short_description = grRITM.cat_item.name + "- Requested For : " + grRITM.variables.requested_for.getDisplayValue() +"\n";
}
}
 
 
})(current, previous);
 
New business Rule
Original Business Rule 
- This business rule was created for the new requirements listed above. . 
Table sc_req_item
When to run after, insert 
script
 
var gr_req = new GlideRecord('sc_request');
gr_req.addQuery('sys_id',current.request);
gr_req.query();
if(gr_req.next()){
gr_req.short_description = current.variables.request_name;
gr_req.description = current.cat_item.name;
gr_req.update();
}
current.short_description = current.variables.request_name; // this part is for setting short desc of RITM
current.description = current.cat_item.name;

 

0 REPLIES 0