- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 09:52 PM - edited 09-23-2024 09:57 PM
Hi,
I have 2 list collector variables called 'select pc' and 'selected pc' (selected pc is hidden in catalog form and visible in task)
now my requirement is what ever i select in 'select pc' variable in form it same should be visible in 'selected pc' variable in task
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 11:08 PM
Hi Dixit,
You can try out these steps - capture select choices, (store and) transfer to Selected variable.
1. Optional - Create Client script:
function onSubmit() {
var selectPCValues = g_form.getValue('select_pc');
g_form.setValue('hidden_selected_pc', selectPCValues); // Optional to store the values in a hidden new variable (incase if changes happen after submission in variable editor)
}
2. Use Business rule to copy data from RITM to SCTASK, create on SCTASK table.
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
var selectedPCs = ritm.getValue('select_pc');
// or if CS is used — var selectedPCs = ritm.getValue('hidden_select_pc');
current.variables.selected_pc = selectedPCs;
current.update();
}
})(current, previous);
Happy learning!
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:30 PM
Hi @dixitreddy
To achieve this functionality in ServiceNow, you can use an 'onChange' catalog client script to transfer the 'select pc' variable value to the hidden variable 'selected pc', which will show on the task form.
Please mark it as 'Helpful' and 'Accepted', if the solution works for you.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 11:08 PM
Hi Dixit,
You can try out these steps - capture select choices, (store and) transfer to Selected variable.
1. Optional - Create Client script:
function onSubmit() {
var selectPCValues = g_form.getValue('select_pc');
g_form.setValue('hidden_selected_pc', selectPCValues); // Optional to store the values in a hidden new variable (incase if changes happen after submission in variable editor)
}
2. Use Business rule to copy data from RITM to SCTASK, create on SCTASK table.
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
var selectedPCs = ritm.getValue('select_pc');
// or if CS is used — var selectedPCs = ritm.getValue('hidden_select_pc');
current.variables.selected_pc = selectedPCs;
current.update();
}
})(current, previous);
Happy learning!
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.