variable editor on request item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-09-2024 09:51 PM
catalog item when hitting submit, I want to put a value in the variable editor in the generated request item. So I want to know how the variable editor in the request item is used in the script and if what I want to do is possible? Or do you have any better suggestion for me?
Thanks in advanceļ¼

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-09-2024 10:06 PM
Variable editor will basically show the field values entered by the user while submitting the catalog.
If you want to set another variable while submission, create a variable in your catalog item and then set the value of that variable using an onSubmit Client script in you catalog item.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-09-2024 10:30 PM
Hi @ma kaiyue,
1-Catalog Client Script: This script runs on the client side (browser) and can be used to perform actions when a user interacts with the catalog item form. It can be used to set or modify variables before submission.
function onSubmit() {
// Assuming you have a variable named 'editor' in the catalog item
g_form.setValue('editor', 'desired_value');
return true;
}
2-Catalog Business Rule: This script runs on the server side and can be used to modify the request item after submission. It can set or change variables in the request item based on certain conditions or logic.
Table: Select "sc_req_item"
When: Select "after"
(function executeRule(current, previous /*null when async*/) {
// Assuming you have a variable named 'editor' in the request item
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item', current.sys_id);
gr.addQuery('sc_item_option.item_option_new.name', 'editor');
gr.query();
if (gr.next()) {
gr.sc_item_option.value = 'desired_value';
gr.update();
}
})(current, previous);
Thank you, please make helpful if you accept the solution.