Apps

Apps

Javascript field name has spaces

Contributor
edited March 2023 in Apps

I have tried back ticks, brackets, everything I can think of


The script below works correctly and provides the results that I expect, but I really need to put Account Level 9 in the var where

Specifically Account Level 9 = Administrative expense

but when I add the field I get nothing. I can see the record in the output when I use the script below. I know it's correct but I am pretty sure it has to do with the fact that the field has spaces it in. The fields I am successful with below all do not. I do not want to go back and remove the spaces in the field name

I have tried this and a bunch of other variations

var where = ['TimeSeriesShort = YTD','RecordType = Standard','MOLongName = November','Account Level 9 = Administrative expense'];

If you could be specific in your response I would greatly appreciate it.

WORKING SCRIPT

var columns = ['RecordType','TimeSeriesShort','MOLongName',`Account Level 9`,`VAR P-A (A)`];

var fields = columns;

var where = ['TimeSeriesShort = YTD','RecordType = Standard','MOLongName = November'];

var query = `/data/v1/${datasets[0]}?fields=${fields.join()}&groupby=RecordType,TimeSeriesShort,MOLongName,'Account Level 9'&filter=${where.join()}`;

Tagged:

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Answers

  • @Jessica

    Hi,

    Please try changing the single quotes or ticks with double quotes. This should work.

    Also, is it a view or a dataset you are trying to build this on? Is it a federated connection?


    Thanks

    'Happy to Help'
  • Contributor

    Building on DDX bricks app

    Can you give me an example of what you are saying above

    do I change everything to single quotes? I started that way and then changed to back ticks when it didn't work


    ticks with double quotes

    like this?

    var columns = ['RecordType','TimeSeriesShort','MOLongName',`"Account Level 9",`"VAR P-A (A)"`];

  • Hi @Jessica

    Something like this - ["RecordType","TimeSeriesShort","MOLongName","Account Level 9","VAR P-A (A)"]

    You can try this. Also if this does not work, try removing the () parenthesis from the name, that could also be a possible reason for it to not work.

    Let me know how it goes.

    Thanks

    'Happy to Help'
  • Contributor

    So this works and the field that has paren in the name, is working it seems like the issue is only because it's the where and groupby?

    var domo = window.domo;

    var datasets = window.datasets;

    var myTable = document.getElementById('myTable');

    var fields = ['TimeSeriesShort','VAR P-A (A)'];

    const where = ['TimeSeriesShort = CM'];

    var groupby = ['TimeSeriesShort'];

    var query = `/data/v1/${datasets[0]}?fields=${fields.join()}&groupby=${groupby.join()}&filter=${where.join()}`;


    further down in script


    function getRow(rowData, index){ 

     var rowEl = document.createElement('tr');

     var td1 = rowEl.appendChild(document.createElement('td'));

     var td2 = rowEl.appendChild(document.createElement('td'));

     td1.innerText = rowData['TimeSeriesShort'];

     td2.innerText = rowData["VAR P-A (A)"]; this row works this or with 'VAR P-A (A)' the results are accurate both

     return rowEl;


    This does not work, I have tried back ticks and single quotes and double quotes unsuccessfully


    var domo = window.domo;

    var datasets = window.datasets;

    var myTable = document.getElementById('myTable');

    var fields = ["Account Level 9 Code","VAR P-A (A)"];

    const where = ["Account Level 9 Code = 600011"];

    var groupby = ["Account Level 9 Code"];

    var query = `/data/v1/${datasets[0]}?fields=${fields.join()}&groupby=${groupby.join()}&filter=${where.join()}`;


    function getRow(rowData, index){  

     var rowEl = document.createElement('tr');

     var td1 = rowEl.appendChild(document.createElement('td'));

     var td2 = rowEl.appendChild(document.createElement('td'));

    td1.innerText = rowData["Account Level 9 Code"];

     td2.innerText = rowData['VAR P-A (A)'];

      return rowEl;

  • Contributor
    edited January 2023

    Hopefully this shorter amount of code will make it easier


    Validated that this works

    const where = ['TimeSeriesShort = CM','Version != OEP_Working','RANK_Version = 1','RecordType = Standard','BA_MA_SSP = Total Company Management View'];


    This is just one of the MANY combinations I have tried that do NOT work. I have tried everything I can think of probably going to file a support ticket on it, back tics, single quotes, double quotes, brackets, underscores, %20 &nbsp still can't figure it out and I cannot change the field name, Account Level 9 Code, has spaces.

    const where = ['TimeSeriesShort = CM','Version != OEP_Working','RANK_Version = 1','RecordType = Standard','BA_MA_SSP = Total Company Management View','[Account Level 9 Code] = 600011'];

  • @Jessica - did you ever find a solution to this? Dealing with the same problem.

  • Contributor

    No, no response or solution. I may submit support ticket

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In