execution order of ritm in a order guide
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2021 04:42 AM
hi all, i wan to control the execution stages of requested items in service catalog via flow design? can anyone help me. like first will be id creation. after the sctask is set to close complete then laptop request should show , after laptop sctask is set to close complete then the next ritm will show like this. i want this to be done in flow design.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2021 03:08 AM
Something like this might do it:
var sys_id_of_common_request = 'a0005bc10721741043e9f7d08c1ed081';
var sys_id_of_catalog_item_waiting_for_user = 'b3f90f4507ed341043e9f7d08c1ed0b9';
var name_of_flag_variable = 'user_has_been_created';
update_flag_variable(sys_id_of_common_request, sys_id_of_catalog_item_waiting_for_user, name_of_flag_variable);
nudge_flow_by_adding_a_useless_work_note(sys_id_of_common_request, sys_id_of_catalog_item_waiting_for_user);
function update_flag_variable (sc_request‿sys_id, sc_cat_item‿sys_id, item_option_new‿name) {
var sc_item_option = new GlideRecord('sc_item_option');
var jq = sc_item_option.addJoinQuery('sc_item_option_mtom', 'sys_id', 'sc_item_option');
jq.addCondition('item_option_new.name', item_option_new‿name);
jq.addCondition('request_item.request', sc_request‿sys_id);
jq.addCondition('request_item.cat_item', sc_cat_item‿sys_id);
sc_item_option._query();
while (sc_item_option._next()) {
sc_item_option.value = true;
sc_item_option.update();
}
}
function nudge_flow_by_adding_a_useless_work_note (sc_request‿sys_id, sc_cat_item‿sys_id) {
var sc_req_item = new GlideRecord('sc_req_item');
sc_req_item.addQuery('request', sc_request‿sys_id);
sc_req_item.addQuery('cat_item', sc_cat_item‿sys_id);
sc_req_item._query();
while (sc_req_item._next()) {
sc_req_item.work_notes = gs.getMessage('User creation is done.');
sc_req_item.update();
}
}
Here you would have a checkbox variable named user_has_been_created in the Laptop requested item, that would be hidden and false by default. An the 1st step in its Flow (or the 1st action in its Workflow) would be a Wait Condition for that variable being true. Of course you can name your variable whatever you want, just update it in the code.
In the the user creation Flow or Workflow you would execute the code above, adjusting of course, the variable values to match real life conditions. If you need to signal several sibling catalog items that the user creation is done, repeat the two function calls for each requested item - in fact for each catalog item of each requested item; don't forget to also update the name of the flag variable - if needed.
E.g:
update_flag_variable(sys_id_of_common_request, sys_id_of_catalog_item_1, name_of_flag_variable);
nudge_flow_by_adding_a_useless_work_note(sys_id_of_common_request, sys_id_of_catalog_item_1);
update_flag_variable(sys_id_of_common_request, sys_id_of_catalog_item_2, name_of_flag_variable_2);
nudge_flow_by_adding_a_useless_work_note(sys_id_of_common_request, sys_id_of_catalog_item_2);
update_flag_variable(sys_id_of_common_request, sys_id_of_catalog_item_n, name_of_flag_variable_n);
nudge_flow_by_adding_a_useless_work_note(sys_id_of_common_request, sys_id_of_catalog_item_n);
Before doing all that, 1st update the Requested for field of the Request to the newly created user. Otherwise all requested items would be ordered for the person who submitted the order guide.