Help with variables being reset to default values.

ClayBenson

New member
Hey everyone!

I've created a few Action Blocks and a single macro that calls them. The flow I expect is as follows (using ✅ to denote steps that work as expected, and ❌ for those that don't)

Trigger:
✅ Notification Received
Actions:
✅ Extract a dollar amount (using RegEx) from notifications, then set in a local variable
✅ Trigger an action block that creates a notification that contains that dollar amount with a "Yes" button and "No" button
✅ "No" button simply closes notification, does nothing else
❌ "Yes" button triggers another action block that will send an API call with that variable.


For some reason, the first action block (which creates the "Yes/No" notification) shows the extracted variable as I'd expect, but when I pass that same variable to the other action block as an input (after clicking "Yes"), that action block sees it as "0.0" (it's a decimal value)

I'm sure I could use a global variable to track this, rather than passing it around through action block inputs, but I really want to avoid using a global variable because multiple triggering notifications would override the value, and make this function less smoothly.

Any idea what might cause this? Happy to share the macro file (though, not sure if I can share the action block too? Can those be exported/shared?)
 

Dimlos

Well-known member
I can export it as .ablock, but I can't attach it to this forum.
You need to upload it to the Template Store temporarily or use some file sharing service.
However, please be careful about your API key and other privacy issues.
 

ClayBenson

New member
I can export it as .ablock, but I can't attach it to this forum.
You need to upload it to the Template Store temporarily or use some file sharing service.
However, please be careful about your API key and other privacy issues.
Thanks for the info, @Dimlos!

I've uploaded them in my Google Drive here

And don't worry, right now I don't have any API keys (or API calls, for that matter) actually hooked up - right now it just triggers a dummy notification in place of the API call (which is how I see that the variable isn't correct).

I've also added a Macro that I'm using to debug this entire thing (Fake_Chase.macro - it sends a notification in place of my banking app doing it)
 

Dimlos

Well-known member
This is a very lazy solution, but I changed the variables passed from Create_Splitwise_Notification.ablock to Send_to_Splitwise.ablock to global variables, as variable passing does not seem to be working.

I have not used action blocks much, so if anyone has a better solution, please let me know.
 

Attachments

  • Create_Splitwise_Notification.jpg
    Create_Splitwise_Notification.jpg
    541.3 KB · Views: 7
  • Configure InputOutput params.jpg
    Configure InputOutput params.jpg
    355.2 KB · Views: 7

ClayBenson

New member
This is a very lazy solution, but I changed the variables passed from Create_Splitwise_Notification.ablock to Send_to_Splitwise.ablock to global variables, as variable passing does not seem to be working.

I have not used action blocks much, so if anyone has a better solution, please let me know.

Thanks!! Yeah, I have a feeling that the local variable is being "lost", and isn't stored as part of the notification (maybe the action "completes" as soon as the notification pops, so the variable goes away?)

I think I'll probably roll with a solution like this too, with the caveat that if multiple notifications come through, only the latest will function.

If anyone else has a solution that could work for this, I'm all ears - thank you for your help @Dimlos !
 

MacroDroidDev

Administrator
Staff member
This seems to be an issue related to the lifetime of the action block (It is removed before the notification button is pressed). I'm looking into a solution.
 
Top