- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 12:04 PM
Hello, everyone, I am working on a script that automatically consumes. It works fine when I use the Script - Background module, but when I use it in a workflow, I get a different result. Basically, in the workflow, it takes the consumable and puts it in both Consumed and In Use state with an empty Display Name and Model.
Before running the workflow, the top row was 60. I entered a quantity of 2 and it got sent to the two top rows.
I just want it to show up as the actual item I selected. I am open to another way to automatically consume. I just need it to work with the workflow.
Here is the script:
var this_consumable = current.variables.alm_consumable;
//The this_consumable variable is a Reference variable used to select the consumable from the available stockrooms.
var this_qty = current.quantity;
var this_user = current.request.requested_for;
current.variables.alm_consumable_pull_from_stock = (" Qty "+ this_qty + "|" + this_consumable.getDisplayValue() );
//this line prints the value to a single line text variable on the Task form.
var new_sys_id = new Consumables().splitForeground(this_consumable, this_qty, '10', '', '', '', '', this_user);
//this is the script include that actually consumes and assigns to the user
Thank you,
CJB
Solved! Go to Solution.
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2018 08:42 AM
With this script, consumableAsset must be the SysID of the consumable not the display value:
new Consumables().splitForeground(consumableAsset, qty, '10', '', '', '', '', requestedFor);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 08:50 AM
Workflows are tricky because they are comprised of many records. The easiest way is honestly to create a new update set, make it your current update set, checkout and publish the workflow without making changes and this will push it into your current set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2018 03:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2018 06:48 AM
Hum not sure what to say here. Just to confirm and I am shooting in the dark here, are you converting the quantity to an integer?
var qty = parseInt(current.variables.quantity, 10);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2018 06:55 AM
Another shot in the dark...does the user who you are using to perform this action have the required roles to update those records?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2018 08:39 AM
Yes, they do. I'm just using system admin.
Could it possibly be the variables I'm pulling? For the Consumable dropdown, I am using Display Name. Is that correct or should it be using another field for the lookup? I tried to set everything up like Michael's screenshot. In the workflow properties, I have the table set to "Requested Item."