Subtracting Quantity of a Consumable using Flow Designer

JordanDR
Tera Contributor

We have a record producer that we use whenever we deploy consumables out of our stockroom. We have a question on the form that asks how many of the items are being removed. 

 

In flow designer when trying to use the transform function for Math -> Subtract, I am only able to hard code a number (1 in this case). In order for multiple items to be consumed and the quantity adjusted accurately, users have to submit the record producer multiple times.

 

So here are my following questions:

1. Is there a way to utilize a data pill inside a transform function to help determine the number to subtract?

2. If the above is not possible, is there another way where I can reduce the quantity of the consumable according to the actual quantity being entered without having the user complete the record producer multiple times?

2 REPLIES 2

Michael H1
Tera Guru

Hi @JordanDR,

I'm not sure if this function will work with Record Producers (still trying to find documentation) but this function appears to work well for marking items as Consumed. You will end up with items on the Consumable (alm_consumable) table marked as Consumed:

 

 

var new_sys_id = new Consumables().splitForeground(this_consumable, this_qty, '10', '', '', '', '', this_user);

 

 

 

The parameter order is as follows: sys_id, qty, status, substatus, asset, stockroom, location, assigned_to. You can view this in the 'Consumables' script include.

In regards to the above, this_consumable refers to the Sys ID of the consumable you want updated, this_qty refers to the quantity passed, 
'10' value is to mark the State as 'Consumed', and this_user is the Sys ID of the user you want to mark as the Consumer.

Anand Kumar P
Giga Patron

Hi @JordanDR ,

You can create Custom action and do necessary calculations and sent it to flow. Refer below link.

https://www.servicenow.com/community/developer-forum/auto-populate-catalog-variables-using-flow-desi... 

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand