how to save a catalog item value into a table form field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2022 11:50 PM
I have a requirement where I need to get values like description, category from my catalog item and save it in request (sc_request) form.
I tried writing a business rule for description field but I'm unable to pass values to the business rule from a catalog item.
Can anyone help me pass both description and category values.
screenshots:
Thank You.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2022 01:03 AM
Hope the Business Rule is on RITM table & not REQ
Try below & confirm the messages you get
(function executeRule(current, previous /*null when async*/ ) {
var reqis = new GlideRecord('sc_request');
reqis.addQuery('sys_id', current.request);
reqis.query();
if (reqis.next()) {
gs.addInfoMessage('Ritm is ' + current.number);
gs.addInfoMessage('Req is ' + reqis.number);
gs.addInfoMessage('Variable desc ' + current.variables.description);
gs.addInfoMessage('Variable cate ' + current.variables.category);
reqis.description = current.variables.description; //replace description1 with correct description variable name
reqis.short_description = current.variables.category; //replace category with correct category variable name;
reqis.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2022 01:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2022 01:59 AM
Hey,
Create an After Insert BR on Requested Item table.
Try below code:
(function executeRule(current, previous /*null when async*/ ) {
var requestGR = new GlideRecord('sc_request');
requestGR.addQuery('sys_id', current.getValue("request"));
requestGR.query();
if (requestGR.next()) {
requestGR.setValue("description", current.cat_item.description);
requestGR.setvalue("short_description", current.cat_item.short_description) ;
requestGR.update();
}
})(current, previous);
Now raise a new request and test
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2022 06:04 AM
Hello NewBiee,
Please refer the below code. It's working correct for me. Select the after insert/update business rule on sc_req_item table.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var req=current.request;
gs.addInfoMessage("Request is "+req);
var grreq=new GlideRecord('sc_request');
grreq.addQuery('sys_id',req);
grreq.query();
if(grreq.next())
{
grreq.description=current.variables.enter_description;
grreq.short_description=current.variables.enter_short_description;
grreq.update();
}
})(current, previous);
Please mark my answer as correct/helpful if it helps you.
Thanks,
Namrata