- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 11:50 AM
Hello everyone,
I have been trying to solve a problem we are having for a while. It is very tedious to try and go through and consume every consumable item that goes out on an RITM. I would like to be able to automate consumption with the flow for these requests. I made a MRVS for the consumables with a qty field in it, my goal is to make it consume the items in the MRVS in the qty specified. I looped through the MRVS in the flow then am telling it to update the items by their sys_id. I then tried to use the below script to consume the items, but I must be doing something wrong. Ether the script is bad, and I need to loop through the MRVS in the script for it to function properly, or I need to create a script action in the flow. Any assistance would be extremely helpful! Below is the script with the variable names I need it to pull from, the MRVS name is consumables_mrvs. The below variables are inside the MRVS.
var this_consumable = fd_data.trigger.request_item.variables.sys_id;
var this_qty = fd_data.trigger.request_item.variables.consumable_quantity;
var this_user = fd_data.trigger.request_item.variables.requestor;
var new_sys_id = new Consumables().splitForeground(this_consumable, this_qty, '10', '', '', '', '', this_user);
Thanks,
Jon
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 04:14 PM
Was able to solve this, if anyone is attempting to consume items from a MRVS this works!
var mrvs = fd_data.trigger.request_item.variables.consumables_mrvs; //MRVS Variable Name
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var this_consumable = row.sys_id; //MRVS Variable
var this_qty = row.consumable_quantity; //MRVS variable
var this_user = fd_data.trigger.request_item.variables.requestor; //Variable from flow
var new_sys_id = new Consumables().splitForeground(this_consumable, this_qty, '10', '', '', '', '', this_user);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 12:09 PM
The above script will update consumables if ran from a background script, I think I just need the variables to populate correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 04:14 PM
Was able to solve this, if anyone is attempting to consume items from a MRVS this works!
var mrvs = fd_data.trigger.request_item.variables.consumables_mrvs; //MRVS Variable Name
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var this_consumable = row.sys_id; //MRVS Variable
var this_qty = row.consumable_quantity; //MRVS variable
var this_user = fd_data.trigger.request_item.variables.requestor; //Variable from flow
var new_sys_id = new Consumables().splitForeground(this_consumable, this_qty, '10', '', '', '', '', this_user);
}