DDX: Getting Data in DDX form

Options

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 ✓
    Options

    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

  • GrantSmith
    Options

    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!**
  • Pritesh
    Options

    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 ✓
    Options

    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); });

  • naveenprabhu811
    Options

    Hey Pritesh,

    I am working on the same issue that you had - DDX: Getting Data in DDX form.

    I want to display rows of 'vendor' table as a drop down in the Ag-Grid cells. I have this table in my manifest.json as below-

    { "dataSetId": "b928d658-dd19-4243-9db3-ce021ce2b8e6",

    "alias": "vendor",

    "fields": [] }

    and this is my domo.get() - domo.get('/data/v1/vendor?fields=vendor_name&limit=1')

    I have questions from your solution as below-

    1. What is datasets[0] in your script? I see that your data name is dataset0 and you are using datasets[0] as the table name inside domo.get()
    2. new Query() is not working for me. what kind of object is this? Should I import that? I get the below error for new Query()

    'Query' is not defined.

    Please help me here. I am stuck with this since a week and need to get the result out.

    Thank you in advance

  • Pritesh
    Options

    Hi Naveen,

    1. 'Query' not defined. Can you paste you code snippet to get more idea? It's javascript legacy api object so shouldn't happen.
    2. You cannot refer your Domo dataset directly in your DDX. You have to first map the dataset(s) that you want to refer in your DDX by choosing them in your mapping section (as dataset0, dataset1 etc.) - see below for example.

  • naveenprabhu811
    Options

    Hello Pritesh,

    Thanks a lot for the reply. 'vendor' is my dataset name in the Domo DDX. I want to display values of 'vendor_name' column in my dropdown

    I have defined this in my manifest as below-

    { "dataSetId": "b928d658-dd19-4243-9db3-ce021ce2b8e6",

    "alias": "vendor",

    "fields": [] }

    I am using Ag-Grid framework of React JS to build the front end interface. Input_variables() is my function call where I need to pass the data to be displayed in the dropdown of each cell.

    I want to display the values returned in Input_variables as a dropdown in 'Brand Name' column in the tool as shown below-

    Below is my function definition-

    function Input_variables(){
    var version ='';

    var query = new Query();

    query

    .select(['vendor_name'])

    .groupBy('vendor_name')

    .limit(1);

    domo.get(query.query(vendor[0]), {format: 'array-of-arrays'}).then(function(result)

    { var row = result.rows[0];

    version = row[0];

    $('#vendor_name').val(version).prop("readonly", true);

    })

    ;};

    I get below error when I run this function

    Can you please look at this set up and help me to get through?

    Thank you in advance.

  • naveenprabhu811
    Options

    Hey Pritesh,

    Did you get a chance look at the above code?

  • Pritesh
    Options

    Hey Naveen - Sorry, couldn't figure it out. I suggest post it as a new thread on community so someone who've encountered similar issue can help.