- 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 07:22 AM
CJB, I created a simple catalog item in my personal dev instance:
I have a simple workflow that has a run script to launch the code below.
var consumableAsset = current.variables.consumable;
var qty = parseInt(current.variables.quantity, 10);
var requestedFor = current.variables.requested_for;
new Consumables().splitForeground(consumableAsset, qty, '10', '', '', '', '', requestedFor);
It works fine in this instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 07:24 AM
Thanks, Michael. I am going to try testing this right now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 07:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 08:06 AM
What release are you on? Wonder if there is a bug. My PDI is Kingston Patch 6 as an example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 08:20 AM
Currently, my company is on Jakarta (we plan on upgrading in a few months).
Is there a good way of copying over this workflow to my personal instance? I want to see if I can get it working on that. Thanks.