The CreatorCon Call for Content is officially open! Get started here.

Inline Scripting - Minus one record from another

StephenL1
Tera Contributor

Hi there,

I've created a "Consume Asset" flow in flow designer. It reads from a record producer where you say what consumable you will be checking out and how many of it.

 

I'm trying to update the consumable record so that it gets the current consumable quantity and takes away the number inputted from it to set the current quantity.

 

The problem is, when using an inline script it will not let me subtract one data pill from another.

What I would like to do:

 

 

var quantity = fd_data._6__look_up_record.record.quantity ;

var takeAway = fd_data._2__get_catalog_variables.how_many_of_this_item_are_being_deployed;

return quantity - takeAway;

 

But this errors out removes the code every time I try to save my flow.

I know that the logic is correct because if I do:

 

 

var takeAway = fd_data._2__get_catalog_variables.how_many_of_this_item_are_being_deployed;

return takeAway - 2;

 

 

or

 

 

var quantity = fd_data._6__look_up_record.record.quantity ;

return quantity -  3;

 

 

It will work fine. For some reason it just wont let me subtract the two variables form each other.

 

For context, quantity is an int and takeAway is a string.

 

Screenshot 2023-01-31 at 5.26.39 PM.png

 

Screenshot 2023-01-31 at 5.26.07 PM.png

 Any help here would be great!

5 REPLIES 5

StephenL1
Tera Contributor

Also tried a for loop and it generally just seems to be that every time you reference a second piece of data, it stops working.

 

var quantity = fd_data._2__get_catalog_variables.how_many_of_this_item_are_being_deployed;

for (let i = 0; i < fd_data._2__get_catalog_variables.how_many_of_this_item_are_being_deployed; i++) 
{
  quantity - 1;
}

return quantity;