Not able to pass variables in a workflow

I am just getting started with workflows and am having difficulty cycling through records. I am trying to use the variables {{first}} and {{after}} to cycle through the records.

fetchAllJobs

  let allJobs = [];
  let hasNextPage = true;
  let afterCursor = null;

  while (hasNextPage) {
    // Call the GraphQL query function with the correct variables
    const response = await getJobberJobs({ first: 10, after: afterCursor });
    
    // Ensure that response structure matches the expected format
    const jobs = response.data.jobs.nodes;
    allJobs = allJobs.concat(jobs);

    // Update pagination variables
    hasNextPage = response.data.jobs.pageInfo.hasNextPage;
    afterCursor = response.data.jobs.pageInfo.endCursor;
  }

  return allJobs;

Any ideas?

Figured it out. In the function I had to use parameters to reference the js block. Then I had to reference the parameter in the variable for the query to run correctly.

1 Like