Catalog item

dixitreddy
Tera Contributor

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

1 ACCEPTED SOLUTION

Akash4
Kilo Sage
Kilo Sage

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!

 

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

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

Akash4
Kilo Sage
Kilo Sage

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!

 

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.