Question- RunJavascript

Hi guys I am trying to build a activity tracker chart in bubble. I have users activities stored in the database.since the activity table only contains the months the users done the activity but I want the chart to display data for all months. I created a javascript function which checks users activities grouping by the month whether for the given month if there is any activity if there is a activity it will be added to the list else 0 will be added to list if there is no activity in that month. I tried to use toolbox plugin’s run javascript for that I made the code separately and tested with constants but when I tried to run it bubble with getting values dynamically it was not working.
If I used the months,ActiveMonths,Activekms as the constants(like the second portion of the image) I get the expected result in kms(the list of numbers) but when use the first portion for the list(the dynamic values) the kms just returns 0…Do any of you guys know how to fix this? Thank you

Run step by step in the debugger, and check the script makes sense after filling in the dynamic data.

Ah yea, Thanks.It was evaluating to a comma seperated string…After spliting it works as expected.

1 Like

Try changing the join with from , to "," since you’re using an array.

image

What you have right now is outputting this:

image

When debugging these sorts of issues, put the script into a text element so you can check the syntax, or do what @mishav suggests and use the step by step to validate it, then you should be good.

In the console, you can see the issue

2 Likes

Hi @pork1977gm thanks for the input. I have a doubt though how did you view the console log outputs in bubble like in your last image

No probs. Normally by pressing F12 but it depends on your browser, or “development tools” option in the settings somewhere.

1 Like