Inline Scripting - Minus one record from another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 05:27 PM
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.
Any help here would be great!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 06:45 PM
Hi @StephenL1 ,
Try the below script and see if its working. In the code I am trying to convert the takeaway to an Integer value. Try and see if it works for you.
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;
var takeAwayInt = parseInt(takeAway,10)
return quantity - takeAwayInt;
Mark Helpful if it helps in solving your query.
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 10:03 AM
Hi Johns,
Unfortunately this didn't seem to work either. Just seems to happen every time I reference a second data pill in a piece of code. I'd also tried converting to int a few different ways with ParseInt(), Number(), and +(). None of them worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 08:08 PM
I have met the same issue。
Inline scripts was removed when saving the flow for unknow reason。
I tried many times and finally it was successful saved。。
But even now i still don't know why they are removed。
Maybe avoid using Inline scripts is a better way。
You can do the logic in a action,and set the action result to the field you want to fill。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 09:12 AM
Hey,
Good to know it's not just me thats having an issue!
When you say use logic in an action, could you specificy what you mean?
My thought was to basically get the inputted number and do a for each loop that would take away 1 quantity for each number that is in the inputted number. But the logic only allows for each to work with a list, not an int. So thats also a bit of a bust 😞 .