• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

JavaScript implementation broken?

Anastasia

Member
We grant multiple automations and courses upon a purchase webhook. We currently pull a row out of a Google sheet to see which items we need to grant. I've been isolating the relevant columns for Teachable by using Javascript code. Code is below, with some example data (of course in my real flow, this data was mapped, not plain text). When we closed shop on the 22nd, this code was working and returning an array of just the teachable column contents. However, at some point during the holidays it started returning an error, saying that there was an additional '}'.

At first I thought there was an issue with the data, and even tried to manually add an array to test it, but it still didn't work. After much trial and error, I am convinced there is something wrong with the current Pabbly JavaScript implementation. For now, I've switched all this code to Python and it works fine (same data). Examples can be found below in the routes of this flow: https://connect.pabbly.com/workflow/mapping/IjU3NjUwNTZlMDYzZTA0M2M1MjZlNTUzYzUxM2Ei_pc

However, @Pabbly, please look into this and let me know if there's something wrong with your code.

I would also welcome suggestions on how to isolate only columns marked with "Teachable Contents" from the objects I'm returning with Google sheets with inbuilt Pabbly tools, to avoid similar breakages in future.

Many thanks,

Anastasia




function extractTeachableContents(arrayOfObjects) {
let teachableContentsValues = [];

if (arrayOfObjects.length > 0 && arrayOfObjects[0].hasOwnProperty('rowValue')) {
let rowValueObject = arrayOfObjects[0].rowValue;

for (let [key, value] of Object.entries(rowValueObject)) {
if (key.includes('Teachable Contents') && value != "-" && value != "") {
teachableContentsValues.push(value);
}
}
}

return teachableContentsValues;
}

// Usage example
let arrayOfObjects = 4. Response Result : [{"rowIndex":303,"rowValue":{"Product ID":"261538","Product Name":"The Natural Solution Series – Platinum – Premium (One-Time-Offer)","Checkout Link":"Checkout / Thanks / Upsell 1 / Upsell 2 / Upsell 3","Launch Specific AC Automation - Purchase":"TNS - 2023 - November - Purchase (626)","Launch Specific AC Automation - Refund":"TNS - 2023 - November - Refunded (627)","Your Logins?":"Your Logins (503)","AC Automation - Purchase":"TNS - Platinum - Premium - Purchase (630)","AC Automation - ...;

output = extractTeachableContents(arrayOfObjects);
 
P

Pabblymember11

Guest
Hey @Anastasia

It seems that based on your workflow's latest history log, the error in the code has been resolved and is now functioning correctly.

2024-01-09_13h53_01.png


Regarding isolating columns labeled "Teachable Contents" from the objects returned via Google Sheets using Pabbly tools, I would appreciate elaborating on how you have used it in the first place.
 

Anastasia

Member
Hey @Anastasia

It seems that based on your workflow's latest history log, the error in the code has been resolved and is now functioning correctly.

View attachment 36344

Regarding isolating columns labeled "Teachable Contents" from the objects returned via Google Sheets using Pabbly tools, I would appreciate elaborating on how you have used it in the first place.
As mentioned in my initial message, I changed all the Flows to Python, which is why it now works. The original code was in JavaScript, and is provided in my above message. Feel free to run it on a test flow with a test array, it returned an error. It stopped working on December 28th.

Re our usecase, we accept orders via WooCommerce, and use the product ID from the order to retrieve a row from a Google Spreadsheet, that contains all the corresponding courses, automations etc. Our Teachable route in that flow isolates the specific cells whose column mention teachable and uses the course ids within to grant the customer courses. Please do have a look through the flow to get an idea of what it does and let me know if you have any questions.
 
P

Pabblymember11

Guest
Sure, I'd be happy to help! Could you please create a short video demonstrating the functionality of the Python code with further action steps? It would be beneficial to see how the code operates and what responses it generates.
 
P

Pabblymember11

Guest
Tried with the following code and it seems to be responding to the JSON array accordingly. Please give it a try and let us know.

2024-01-10_12h00_03.png


function extractTeachableContents(arrayOfObjects) { let teachableContentsValues = []; if (arrayOfObjects.length > 0 && arrayOfObjects[0].hasOwnProperty('rowValue')) { let rowValueObject = arrayOfObjects[0].rowValue; console.log("Row Value Object:", rowValueObject); // Debugging: Check the rowValueObject for (let [key, value] of Object.entries(rowValueObject)) { console.log("Key:", key, "Value:", value); // Debugging: Log key-value pairs if (key.includes('Teachable Contents') && value !== "-" && value !== "") { teachableContentsValues.push(value); } } } return teachableContentsValues; } // Usage example let arrayOfObjects = pass JSON array here; // Function call let result = extractTeachableContents(arrayOfObjects); return(result); // Output the extracted values to the console
 

Anastasia

Member
Hi there. I tried it and it works, but that doesn't make sense, because it's more or less the same as my original code, other than the debugging logs and the strict equality check versus the loose one I used. In fact, after that, I tried my old code again and it no longer returns an error and works fine. Was there something wrong Pabbly-side that is now fixed?

Please do let me know if something changed because if the code stopped working before, will it do it again?

To also not run such a risk in future, can you help me figure out how to do that with inbuilt tools?
 
P

Pabblymember11

Guest
We've made a small adjustment within the code comments on Pabbly's Code by Pabbly action step.

This change ensures that the action step will function as intended from now on.
 

Anastasia

Member
Hi Supreme. I appreciate the clarification. I suppose it would have been helpful to be precise in the first instance that the change needed was within the Pabbly structure and not my initial code (as it now works) because otherwise you leave the user chasing bugs that don't exist. But I do appreciate the quick fix and attention.

Having said that, and knowing the needs of my flow, can you figure out a way to achieve what we need to do with inbuilt tools rather than code? I'm a bit wary after this issue arose.
 
P

Pabblymember11

Guest
Having said that, and knowing the needs of my flow, can you figure out a way to achieve what we need to do with inbuilt tools rather than code? I'm a bit wary after this issue arose.
Have you given the Line Itemizer action step a try? It's designed to provide values in a Comma Separate format, making it really handy for your needs. Unfortunately, there isn't any other option available that similarly separates the key and values. Give the Line Itemizer a shot it might just be the perfect solution you're looking for!

1704889535534.png
 
Top