Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
JS compiling information from looped Promises? (w/ Tableau API)

I am trying to use the tableau JS API https://help.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_ref.htm to gather all the data from every "worksheet" object to do some more complex behavior but I am having trouble understanding how to use the promises within loops. I've used when().then() with ajax before, but not much other experience with promises.

Worksheet -> Marks -> Pairs -> key/value
  • I start with a sheets object variable that is instantiated with "worksheets".
  • I loop through each "worksheet" to get the "marks" which has data key/value "pairs".
  • I save every data pair into another object variable markpairs_object.
  • The part I have issues with is figuring out how to use the final object variable markpairs_object because it's always empty at execution time.
sheets[window][section] = tableau "worksheets".

markpairs_object = [];
for(var section in sheets){
    for(var window in section){
        // ASYNC getting marks
        sheets[section][window].getSelectedMarksAsync().then(function(marks){
            for(var markIndex=0; markIndex<marks.length; markIndex++){
                var pairs = marks[markIndex].getPairs(); // I don't think this is ASYNC
                for(var pairIndex=0; pairIndex<pairs.length; pairIndex++){
                    var pair = pairs[pairIndex];
                    // save pair info to an overall object variable
                    markpairs_object[pair.fieldName] = pair.formattedValue;
                }
            }
        });
    }
}

//loop through object variable to make sure it worked
whatever I do here shows empty

I've tried:

  • using callbacks
  • moving different things into their own functions but didn't understand how to implement await/async here
  • another .then() after the getSelectedMarksAsync().then() but that would only get the pairs for one worksheet at a time if it worked (it didn't)
  • creating flag variables to try to indicate when pairs data has been saved

etc. but the object is always empty at the time of execution and I could not understand how to get this to work correctly.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!