Add the ability to do math on Variables

I have a numeric variable and I would like to pass it to my IFTTT applet (as Value1) after doing some math on it (for example dividing by 100). Is there any way to do this? The problem I had is that I couldn’t control the value that the numeric variable was set to. So it would be set to a number but the number that I needed to pass on needed to be divided by 100.

1 Like

Just in case this helps anyone who is looking to do some math on variables, we do have the option to add/subtract a value to/from a numeric variable in Apilio in IFTTT as a action:

And it looks like this:

1 Like

It’s possible to do more complicated mathematical functions than just add/subtract, if you modify the IFTTT Applet with JavaScript filter code.

For example, presuming you wanted to divide a variable by 100. The Apilio LogicBlock sends the variable’s value in ‘Value1’ as an event action.

Where ‘variableToSend’ is the name of your numeric variable.

2 Likes

Then in the IFTTT Applet that receives that event, click the + between your IF and THEN…

2 Likes

… and select ‘Add filter’:

You can then manipulate the actions that are performed on the trigger data.

Apilio.numericVariableSetValueUpdates.setVariableValue(
  String(
    parseFloat(Apilio.iftttActionReports.ApilioValue1)/100
    )
)

^ this JavaScript will divide the variable by 100.

(Sorry for the thread-spamming. As a new user, it wouldn’t let me put all this in a single post).

4 Likes

@Giles thanks for your creative idea and welcome to the forum!
Great solution if an IFTTT applet is involved anyway.

2 Likes

Great suggestion. I’ve always struggled with iFTTT filters.

2 Likes