- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:19 AM
- Created a variable named "priority" in catalog item as type (Select box)
- Added choices as High, medium and low with values 1, 2 and 3.
When submit the catalog item form with priority choice according the value, Requested item (sc_req_item) "priority" field should change. How can I implement that ?
(Catalog item priority field)
(Requested item priority field)
(Note: The "priority" field in Requested item (sc_req_item) is not read only)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:37 AM
Hello,
You can use a BR (On create) to update and map cat_item priorities with sc_requested_item. Idealy you can use the same values for both and hide options that you don't need
(function executeRule(current, previous /*null when async*/ ) {
// If cat_item choices == sc_req_item choices
current.priority= current.variables.priority;
//else If cat_item choices != sc_req_item choices
var priority_map={"high": 1,"low": 5};
current.priority= priority_map[current.variables.priority];
})(current, previous);
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:37 AM
Hello,
You can use a BR (On create) to update and map cat_item priorities with sc_requested_item. Idealy you can use the same values for both and hide options that you don't need
(function executeRule(current, previous /*null when async*/ ) {
// If cat_item choices == sc_req_item choices
current.priority= current.variables.priority;
//else If cat_item choices != sc_req_item choices
var priority_map={"high": 1,"low": 5};
current.priority= priority_map[current.variables.priority];
})(current, previous);
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:44 AM
you must be using workflow or flow for your catalog item
in that workflow run script do this
current.priority = current.variables.priority; // ensure choice values are same for field and the variable
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
04-17-2023 02:49 AM
is it possible to use any onsubmit client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:52 AM
onSubmit on catalog item won't work as by that time RITM is not yet generated
It can be done only from Workflow or Flow which is linked to your catalog item
OR
you can use before/after insert BR on RITM table -> This I won't recommend as you can directly add the logic in your workflow or flow and no need to create an extra component i.e. BR
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