cancel
Showing results for 
Search instead for 
Did you mean: 

Math operations with Collections fields

ArturoElosu_Die
Level 2
Hi! First of all, I'm new with BP.
My problem begins with an app that gives me x number of math operations. I get those operations with App Modeller within a Collection. I need to solve those operations and save them (with the answer) in an excel file.
So, I don't know how to do such operations. First field is numeric, ok. Second field is the operator. And third field es numeric.
Is there any way I can do a math operation with those parameter? I tried to simply use [numer]+[operator]+[number] but I can't... Also tried to use ToNumber([operator]) but it doesn't work either....

Thanks!
1 REPLY 1

Hi Arturo,

The problem you are facing seems to be as you get all these fields as Text values. Moreover, you can convert the number fields into Number values which you actually are doing correctly however, you can't convert the operator symbol that you receive as a string into a Blue Prism arithmetic function operator just by using [operator].

Here, what I would suggest is while you are iterating over your collection to get all these values, use a Choice stage and in that choice stage, use different conditions where you can evaluate the value of the [operator] field that you are receiving and based on that use the appropriate expression. For example, If the condition is [operator] = "+", then use a Calculation stage for that node link with the expression as [number1] + [number2]

So you would actually need to manually write the operators like +, -, *, / for them to work properly as they can't be type casted.

Hope this helps to resolve your query!
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.