Set catalog variable value to a field on table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:11 AM - edited 02-20-2025 07:13 AM
I created a new custom field called "Activity" on the sc_req_item table for reporting purposes. We have a "universal" variable throughout most of our catalog items called "Select Action Type". I want this "Select Action Type" field's value to populate in the "Activity" field so that a user could easily report on the "Activity" field for all catalog items. This is the client script I wrote, but it's not working, can someone tell me what I'm doing wrong?
function onSubmit() {
var actionType = g_form.getValue('select_action_type');
g_form.setValue('u_activity', actionType);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:41 AM
you can use after insert business rule and set
current.u_activity = current.variables.select_action_type;
current.setWorkflow(false);
current.update();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2025 04:16 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:42 AM
Is this a catalog client script? If so it does not have access to the fields on the sc_req_item table. Also g_form only work if the field is visible on the form. So your custom field would not be visible on the form when the request is submitted.
You best bet would be to do a before insert business rule on the sc_req_item table. The code would be simple as below.
(function executeRule(current, previous /*null when async*/) {
current.u_activity = current.variables.select_action_type;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:43 AM - edited 02-20-2025 07:43 AM
Hi @smahmud
You can write before insert BR on RITM Table to update the Activity field
if(current.variables.select_action_type.toString() != '' )
current.u_activity = current.variables.select_action_type;
Add proper conditions to your BR so that it triggers for specific catalog items which has action type variable.
If It's for a single catalog item then you can simply use 'Update record' action in your catalog flow.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP