Can't access output of javascripttoBubble plugin within reusable element

I am using the javascripttobubble plugin and struggling to access the output of the function.

I have built an iOS journal app. I’ve included end to end encryption so that the journal entries remain private to the user. As part of my app I have a list view of all entries that a user has uploaded (see screenshot).

Each entry is displayed using a reusable element within a repeating group. Before the reusable element is displayed the journal entry needs decrypting before being displayed as readable text. I’m using the run javascript plugin to decrypt the text and I use this in other places too so I know my code is working. I have also included logging in the js code so, again, I know the javascript code is running. The issue I’m having is then being able to access the output from the javascript using javascripttoBubble plugin - it just won’t appear. I have used the same method elsewhere in my app and have successfully accessed the output but I cannot workout why this instance is not working and wondered whether it is some nuance with it being with in a reusable element?

Here is my javascripttoBubble element set up:

Here is my javascript code to decrypt the journal entry used in my workflow and return the decrypted text using the javascripttoBubble element:

I’m trying to set the output as a state on an element using this:

Here’s the logs to show that the js code is decrypting the text (I’ve commented out the logging of the encryption key before running this):

@drmattcrooks why are you not checking the “Trigger event” checkbox in the “JavascripttoBubble decrypt_summary” element?

Then the set state action should be called inside the ‘Javascript to bubble event’ where the selected element for that event would be your “JavascripttoBubble decrypt_summary” element

Thanks for replying!

I’ve tried checking the “Trigger event” box and then created this workflow - is that what you meant? This still doesn’t work - the workflow isn’t being triggered.

yes @drmattcrooks this is what I mean
there are 2 ways to debug what is wrong.

  1. move the console.log in your javascript code to come after the bubble_fn_decrypt_summary function is called instead of before it so as to see if the console is still triggered.
  2. In your javascripttobubble event make step 1 alert any message (the message should include this javascripttobubble value) and see if the alert is shown on the app.

Let us know what you find.

I’ve tried both of those and still nothing. I added a console log after the bubble_fn_decrypt_summary and it appears in the logs. In the screenshot of the workflow above it hides the grey horizontal bar (shown in the previous screenshot of the app) and displays the text value from the bubble_fn_decrypt_summary instead - this isn’t happening which is why I don’t think the workflow is being triggered by the javascripttoBubble event.

Also added a navigation to a different page of the app in the javascripttoBubble element event workflow and it’s not redirecting. I’ve also tried setting the RG to just 1 row so that there is just one instance of the reusable element and still nothing

Check that there are no extra spaces in the Input fields where you specify the function names.

You’re better off writing a plugin for this. You already have the script. It’s safer to store your encryption keys as a plugin key instead of an input field.

I’ve tried looking for white space and even copied the elements from other places in the app that do work, but they still don’t work here.

I haven’t looked into creating my own plugin before but might take a look. I can’t set the encryption key as a plugin key because I want to use a different key per user of the app so that it is fully end to end encrypted. If I used a plugin in key then I could just decrypt it myself.

Add the current cell index to the suffix like this “decrypt_summary_1”. Both in javascripttoBubble element and your js code snippet. This should help

@marpas I had high hopes for this but still couldn’t get it to work. Possibly because I don’t think it’s possible to use dynamic naming on an element, which would be needed to access the output.

I managed for come up with a fix for this. I had to decrypt the text of every value in the repeating group using :each item's journal_summary on my RG data and passing that into a javascript code. Then I saved that as state on the repeating group. Then to display the decrypted entry in a specific cell I was able to use the cell’s index to pull out the correct value from the full list. Feels a bit hacky though and I had to remove the reusable element because I couldn’t pass the full list of decrypted journal entries as a state into a reusable element within an RG.

This topic was automatically closed after 70 days. New replies are no longer allowed.