DDX: Getting Data in DDX form

Hi,

I'm trying to bring in data in a DDX form, from a Domo dataset column using domo.get api using the following code.

But I keep getting [object Promise] as a response. All I'm trying to do is getting the distinct value of column "Version" and populate in one of the DDX form input. The value in this column is same for all rows.

Below is how it looks overall…

Tagged:

Best Answer

  • Pritesh
    Pritesh Member
    Answer ✓

    Not sure if using API directly works from the DDX form window console as I was not able to get data with that. I could finally make it work by using the Query object, however - as following…

    var version ='';
    var query = new Query();
    query
    .select(['Version'])
    .groupBy('Version')
    .limit(1);
    domo.get(query.query(datasets[0]), {format: 'array-of-arrays'}).then(function(result){
    var row = result.rows[0];
    version = row[0];
    $('#Version').val(version).prop("readonly", true); });

Answers

  • You need to do something with the promise which in simple terms is just waiting for the data to return.

    You can do something like this to do something with the data when your query is finished running

    domo.get('/data/v2/dataset?limit=100')
        .then(function(data){
          doSomethingWithTheData(data);
          console.log("data", data);
        })
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Hi @GrantSmith - Thanks for the response. But I just want to populate the returned data from this query in an input box, I imagine it's "array-of-arrays" but it should at least show it there right? At least I want to confirm that the query did work — I saw in one of the articles that you could do "console.log()" and "debugger" but that doesn't work in the "Edit card" preview, I imagine it's working only in an IDE (like Visual Studio Code). Is there a way to test if the data is actually retrieved?

  • Pritesh
    Pritesh Member
    Answer ✓

    Not sure if using API directly works from the DDX form window console as I was not able to get data with that. I could finally make it work by using the Query object, however - as following…

    var version ='';
    var query = new Query();
    query
    .select(['Version'])
    .groupBy('Version')
    .limit(1);
    domo.get(query.query(datasets[0]), {format: 'array-of-arrays'}).then(function(result){
    var row = result.rows[0];
    version = row[0];
    $('#Version').val(version).prop("readonly", true); });