Need Help - Javascript2Bubble value is empty

I have placed a J2B element to extract resume text with a regular expression. It successfully extracts the content I need and stores it with the correct data type (I confirmed this with Chrome Inspector). However, the value just can’t be sent back to J2B (the J2B value is empty). I have spent several hours troubleshooting and can’t fix it. Any suggestions (like how to debug, anything I can check, …) would be highly appreciated. Thank you!

Screen Video

If you haven’t done so already, try adding a pause before using the J2B value.

1 Like

Is your J2B element visible on load?

Yes, this J2B is visable on page load.

I add 10 second before send back value to bubble, but the J2B value is still empty.

function extractWorkEntries(parsedResume) {
    const workEntryRegex = /###\s+-\s+Company-\d+:\s+(.+?)\n\s+-\s+Title:\s+(.+?)\n\s+-\s+Start\s+Date:\s+(.+?)\n\s+-\s+End\s+Date:\s+(.+?)\n\s+-\s+Description:\s+((?:(?!###\s+-\s+Company-\d+:|\n###\s+-\s+School-\d+:|\n- Skills:)[\s\S])*)/g;

    let match;
    const workEntries = [];

    console.log("Parsed Resume:", parsedResume); 

    while ((match = workEntryRegex.exec(parsedResume)) !== null) {
        console.log("Matched Entry:", match); 

        workEntries.push({
            Company: match[1].trim(),
            Work_Title: match[2].trim(),
            Start_Date: match[3].trim(),
            End_Date: match[4].trim(),
            Work_Descriptions: match[5].trim().replace(/\s+- /g, '\n- ')
        });
    }

    console.log("Work Entries:", workEntries); 

    console.log("Waiting for 10 seconds before passing the value..."); 

    setTimeout(function() {
        console.log("10 seconds passed. Now passing the value to bubble_fn_extractWorkEntries_1."); 
        bubble_fn_extractWorkEntries_1(workEntries);
    }, 10000); // pause 10 s
}

const resumeText = properties.param1; 
console.log("Resume Text from param1:", resumeText); 
extractWorkEntries(resumeText);

I think maybe it is the data type error. J2B value list is not a real list. It is an object, I remember. But you passed a list. You may check the plugin’s doc.

1 Like

@jonathan21
Hi Jonathan, thanks. I set the Java script to send message back with JSON format and it works. Now The J2B value is a JSON format’s text.
Do you know how to transfer this JSON text into a real JSON ? Then I can create the final data I need with a backend API workflow.

Sorry, I was wrong just now. I checked the doc. The value list is a list.
However, the issue is still around data format. J2B element only accept simple data types but you pushed “object” into the list. I think you can use outputlist1 to outputlist 4 to solve your problem.
I am testing another method to transfer more than 4 paras in a list by using queue. If I succeed, I will let you know.

I have done with demo. It can pass ultimate fields to database now.
this is the preview: Bubble | No-code apps
this is the editor : Pass Object to J2B | Bubble Editor

Hi Jonathan,
Thanks! After watching your example, I understand how the javascript element works in Bubble. Your help was invaluable to me!

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