Multi step request process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 11:13 AM
I have a business need to have a set of requests that can read from each other. Essentially the client comes in and starts the process with an initial request and when that one gets done, a second request one could be triggered and so on down the line to a potential of four request.
There will potentially be fields that I need to share from each step along the way.
If the process makes it to the end and all the requests are completed, I will need to gather the info from each one to then populate an entry in a table.
Is this even possible, can I lookup variable info from a completed request and pull it into a current request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 09:24 PM
Hi @ChrisLawer ,
You can achieve this by using Flow Designer and Catalog Items in ServiceNow, you can follow this approach:
You start by designing a Catalog Item that collects the necessary variables from the user. When this item is submitted, a flow is triggered. Inside the flow, you can use the "Get Catalog Variables" action to retrieve the values submitted with the catalog item. These variables can then be used to populate fields in the current request or passed to another catalog item submission.
To submit another catalog item from within the flow, use the "Submit Catalog Item" action. This allows you to chain requests by submitting a second catalog item and passing in values from the first one using the variables you retrieved earlier. You can repeat this process, each time using the variables from the previous step to populate the next.
At the end of the chain, you can use another flow or a script to gather all the variable data from each request and populate a final record in a custom table.
Mark this as helpful and correct, if this helps you.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2025 05:20 PM - edited 06-28-2025 05:21 PM
Hi Chris,
Here's a simple solution using custom variables and a business rule:
Required Variables to be created:
- u_request_chain_id - Links all requests (If you already have any variable unique for all 4 requests you can use that)
- u_step_number (Integer) - Step sequence (1, 2, 3, 4)
Final Table Fields:( sample)
Create u_your_final_table with:
- u_chain_id (String)
- u_step_1_request (String) - Request number
- u_step_1_description (String) - Short description
- u_step_2_request (String)
- u_step_2_description (String)
- u_step_3_request (String)
- u_step_3_description (String)
- u_step_4_request (String)
- u_step_4_description (String)
- u_process_started (Date/Time)
- u_process_completed (Date/Time)
- u_initiated_by (String)
BUSINESS RULE CREATED TO RUN AFTER REQUEST4 GET COMPLETED:
- Fetches all 4 requests using the chain ID
- Grabs standard fields like request number, description, assigned_to, etc.
- Populates your final table with data from each step
- No need for custom step value fields// Business Rule Configuration:
// Table: sc_req_item (or your request table)
// When: After
// Insert: false
// Update: true
// Condition: current.state == 3 && current.u_step_number == 4 // Adjust state value as needed(function executeRule(current, previous) {
// Only run when step 4 request is completed
if (current.u_step_number != 4 || current.state != 3) {
return;
}
var chainId = current.u_request_chain_id.toString();
if (!chainId) {
gs.log('No chain ID found for request: ' + current.number);
return;
}
// Query all requests in this chain
var requestData = {};
var gr = new GlideRecord('sc_req_item'); // Change to your table name
gr.addQuery('u_request_chain_id', chainId);
gr.orderBy('u_step_number');
gr.query();
while (gr.next()) {
var stepNum = gr.u_step_number;
requestData['step_' + stepNum] = {
request_number: gr.number.toString(),
sys_id: gr.sys_id.toString(),
short_description: gr.short_description.toString(),
description: gr.description.toString(),
state: gr.state.toString(),
created_by: gr.sys_created_by.toString(),
created_on: gr.sys_created_on.toString(),
assigned_to: gr.assigned_to.getDisplayValue(),
// Add any other fields you need from the request
work_notes: gr.work_notes.toString()
};
}
// Validate all 4 steps are complete
if (Object.keys(requestData).length < 4) {
gs.log('Not all steps completed for chain: ' + chainId);
return;
}
// Insert into your final table
var finalRecord = new GlideRecord('u_your_final_table'); // Change to your table name
finalRecord.initialize();
// Populate with data from all steps
finalRecord.u_chain_id = chainId;
finalRecord.u_step_1_request = requestData.step_1.request_number;
finalRecord.u_step_1_description = requestData.step_1.short_description;
finalRecord.u_step_2_request = requestData.step_2.request_number;
finalRecord.u_step_2_description = requestData.step_2.short_description;
finalRecord.u_step_3_request = requestData.step_3.request_number;
finalRecord.u_step_3_description = requestData.step_3.short_description;
finalRecord.u_step_4_request = requestData.step_4.request_number;
finalRecord.u_step_4_description = requestData.step_4.short_description;
// Additional fields
finalRecord.u_process_started = requestData.step_1.created_on;
finalRecord.u_process_completed = current.sys_updated_on;
finalRecord.u_initiated_by = requestData.step_1.created_by;
var finalSysId = finalRecord.insert();
if (finalSysId) {
gs.log('Successfully created final record: ' + finalSysId + ' for chain: ' + chainId);
// Optional: Update all requests in chain with reference to final record
var updateGr = new GlideRecord('sc_req_item');
updateGr.addQuery('u_request_chain_id', chainId);
updateGr.query();
while (updateGr.next()) {
updateGr.u_final_record_id = finalSysId;
updateGr.update();
}
} else {
gs.error('Failed to create final record for chain: ' + chainId);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 10:43 AM
Thank you all for the feedback. We decided to go with a custom table solution similar to what venkat917181
suggested.