• 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

issue with workflow

lannmann1

Member
Hi Pabbly Team,

We're encountering a persistent issue with the "Code by Pabbly -> Run JavaScript (Beta)" action step (currently Step 8) in our workflow [Optional: Add Workflow ID if easily available] and need assistance.

Workflow Context:

The overall goal is to send personalized newsletters. Inside an Iterator loop (Step 6, iterating over subscribers from Step 2), we have a Filter (Step 7) checking for active status. Step 8 (the Code step) is intended to:

  1. Receive the full list of articles (an array of objects fetched in Step 4 via API, output as {{4.data}}).
  2. Receive the current subscriber's preferred tags (a comma-separated string from the Step 6 Iterator, output as {{6.preferred_tags}}).
  3. Receive a cutoff date string (from Step 3 Date Formatter, output as {{3.result}}).
  4. Filter the allArticles array based on the cutoffDateString and tag overlap with subscriberTagsString, returning the top 3 matches.
Steps 2, 3, 4, 6, and 7 have been tested successfully and provide the expected data structures.

The Problem(s) in Step 8 (Run JavaScript):

  1. Missing "Input Data Mapping" UI: The primary method we expected to use for passing data into the Javascript environment – the key-value mapping section typically found below the code editor box – appears to be missing or inaccessible in the UI for this step instance. We have scrolled down and checked carefully, but cannot find the section to define input keys (like all_articles) and map values ({{4.data}}). This prevents us from using the standard method of passing data via the function argument (async function run(input_data)).
  2. Inline Mapping Syntax Errors: Based on Pabbly examples suggesting inline mapping is possible (inserting {{...}} tags directly into the code), we attempted this:
    JavaScript

    async function run() {
    const allArticles = {{4.data}} || [];
    const subscriberTagsString = "{{6.preferred_tags}}" || '';
    const cutoffDateString = "{{3.result}}";
    // ... rest of filtering logic ...
    }

    While mapping the simple string values ({{6.preferred_tags}}, {{3.result}}) within quotes seems okay, including the array mapping {{4.data}} consistently results in SyntaxError: Unexpected token '{' (or similar, like Unexpected token 'l') when testing the step. This suggests Pabbly's replacement of the {{4.data}} tag (which represents a JSON array [{...},{...}]) is generating code that the Node.js v18.x environment cannot parse correctly before execution. Attempts to wrap {{4.data}} in JSON.parse() also resulted in similar syntax errors.
Summary:

We are currently blocked from using the "Run JavaScript" step effectively because: a) The standard Input Data Mapping UI section seems to be unavailable. b) The alternative inline mapping method fails with SyntaxErrors when mapping array data from a previous API step ({{4.data}}).

Request:

Could you please investigate why the Input Data Mapping section might be missing for this step instance in our workflow? Alternatively, could you clarify the correct syntax or method for reliably passing an array (like {{4.data}}) returned from a previous API step into the Javascript code environment using the inline mapping method without causing SyntaxErrors during parsing?

We have already attempted standard troubleshooting like Refresh Fields, re-testing previous steps, and browser refreshes.

Thanks for your help.
 
Hello @lannmann1,

Could you please provide us with the Workflow URL where you are facing this issue? This will help us investigate the problem more effectively and assist you accordingly.

AD_4nXeajowMT9Pl2KC0vTcMTY7VC06LwJR_Ap20VfhU8S-Sb3B0mpmZCDxs0JC7mmMLeoAyT2wW4VMsx6S4yaZeYcN4uxmMPX7LNCaAPCPsUQiVw7W4vLzavNkYJtRdfNicK2hHzlYd
 

lannmann1

Member
Subject: Issue with Code by Pabbly (Run JavaScript) Step - Input Data Mapping Not Working

Workflow Step Details:


  • Step Type: Code by Pabbly
  • Action Event: Run JavaScript (Beta) (Node.js v18.x environment)
  • Current Step Number: Appears as Step 7 or 8 in our workflow.
  • Goal: To filter an array of articles based on date criteria and tag overlap with subscriber preferences within an Iterator loop.
Inputs Required by Code:

  1. all_articles: An array of objects from Step 4 (API Call - {{4.data}}).
  2. subscriber_tags_string: A comma-separated string from Step 6 (Iterator - {{6.preferred_tags}}).
  3. cutoff_date_string: A date string from Step 3 (Date Formatter - {{3.result}}).
Problem Description:

We are unable to successfully pass the required input data (specifically the all_articles array from Step 4) into the Javascript code environment. We have encountered issues with both potential methods:

  1. "Input Data Mapping" Section Issue: The standard UI section typically located below the Javascript code editor, used for defining key-value input mappings (e.g., Key: all_articles, Value: {{4.data}}), appears to be missing or inaccessible in our workflow for this specific step instance. We cannot find or use this section to map the inputs. Consequently, writing code that expects data via an input_data argument (e.g., async function run(input_data)) fails with ReferenceError: input_data is not defined.
  2. "Inline Mapping" Failure: Following Pabbly examples that show inserting mapping tags directly into the code using the "Insert Data from Previous Step" helper (located below the code box):
    • We confirmed that clicking items in the helper incorrectly inserts the full descriptive text and sample value (e.g., {{ 4. Data 0 Article Id : test_article_001 }}) instead of the variable tag ({{4.data}}).
    • Even when we manually construct the code with the correct variable tags (e.g., const allArticles = {{4.data}};), testing the step fails with SyntaxError: Unexpected token '{' (or similar) specifically when the {{4.data}} array mapping is included. This suggests Pabbly's internal replacement mechanism for inline array variables is generating invalid Javascript before execution. Mapping simple string variables inline (e.g., {{6.preferred_tags}} inside quotes) does not seem to cause this syntax error on its own.
Summary:

We are blocked because the primary method (Input Data Mapping section) seems unavailable/broken in the UI, and the alternative method (inline mapping) fails with Syntax Errors when attempting to insert the necessary array data ({{4.data}}).

Request:

Could you please investigate why the "Input Data Mapping" section might be missing or non-functional for this "Run JavaScript (Beta)" step in our workflow? Additionally, could you look into the SyntaxError that occurs when attempting to use inline mapping for an array variable ({{4.data}}) returned from a previous API step?

We need a reliable way to pass the array from Step 4 into this Javascript code step.
 

ArshilAhmad

Moderator
Staff member
Are you able to execute this code successfully in an online JS compiler? If you are facing issues with the online compiler as well, then I’m afraid we won’t be able to assist you with coding-related issues, as it is beyond our scope of expertise.
1746049939381.png
 
Top