Fetch custom field data automatically to a catalog item variable dynamically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 07:51 AM
Hi All,
Please help me out to find the solution of mentioned requirement .
Requirement is I have 3 custom field (string) in a table . Also I have a catalog item with same variables. I want to fetch value from 3 custom field to variables in catalog item dynamically. If I write 'test' on custom field of the table then it should automatically reflect on that catalog item variable. If I leave blank then variable should be blank.
I also tried a client callable script include but did not get desired result.
Please reply asap .
@Ravi Gaurav ,@Sandeep Rajput, @AG - LearnNGrow, @Ankur Bawiskar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 12:03 PM
And you set this up as a before update business rule correct? Also can your share your conditions on when this need to run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 12:17 PM
Yes I set this as Before Update and selected sc_catalog_item as table.
Condition is that a reference type variable is there in catalog which redirect to that custom table.
So when I select the record from that table the script should run to populate the field values in it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 01:56 PM
I'm note sure I understand what you are asking for then. Is this happening when someone is submitting the request? Where are the custom fields and how do they fill them out compared to variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 09:25 AM
Hi @1_DipikaD
One approach is to use Business Rule .
script :-
var tableName = 'your_table_name';
var catalogItemName = 'your_catalog_item_name';
var customField1Name = 'custom_field_1';
var customField2Name = 'custom_field_2';
var customField3Name = 'custom_field_3';
var variable1Name = 'variable_1';
var variable2Name = 'variable_2';
var variable3Name = 'variable_3';
// Get the current record
var gr = new GlideRecord(tableName);
gr.get(current.sys_id);
// Get the values of the custom fields
var customField1Value = gr.getValue(customField1Name);
var customField2Value = gr.getValue(customField2Name);
var customField3Value = gr.getValue(customField3Name);
// Get the catalog item
var catalogItem = new GlideRecord('sc_cat_item');
catalogItem.get(catalogItemName);
// Update the variables in the catalog item
catalogItem.setValue(variable1Name, customField1Value);
catalogItem.setValue(variable2Name, customField2Value);
catalogItem.setValue(variable3Name, customField3Value);
// Save the changes
catalogItem.update();
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 09:59 AM
I think it fetch for all records. Right ?
But I want for a specific record of the table. In that record whatever is the field values it should be populate on variables.
Is there any method to achieve this ?