Browser output of API queries with Output & Debug doesn't show Data

Are you sure the Debug checkbox is not enabled for the database query step??
If it is, turn it off. It should not be enabled!

The error problem is being introduced when I extend the API to then “Export CSV File”

BEFORE that action is added to this API I successfully get back data in the browser like this –

{"query":[
{"apo_Kunden_ID":740770,"Apothekenname":"Greif-Apotheke","Strasse":"Hannes-Meyer-Platz 25","PLZ":18146,"Ort":"Rostock","inhouse_training":null,"peremail":null,"partner":null,"kontakt_email":null},{"apo_Kunden_ID":741220,"Apothekenname":"Schlo\u00df Apotheke Tegel","Strasse":"Berliner Str. 6","PLZ":13507,"Ort":"Berlin","inhouse_training":null,"peremail":null,"partner":null,"kontakt_email":null},
{"apo_Kunden_ID":501556,"Apothekenname":"Bad-Apotheke Binz","Strasse":"Friedrich-Ebert-Str. 5","PLZ":18609,"Ort":"Ostseebad Binz","inhouse_training":"Ja","peremail":"Ja","partner":"Harlan Sanders","kontakt_email”:”sanders@xahoo.com"}]}

I then add to the same query this and save – this time with no header & the query itself was checked for Output but not checked for “debug”–

Then I ask for the browser output –

{"code":0,"file":"\/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/modules\/export.php","line":29,"message":"Data is not an array.","trace":"#0 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/lib\/App.php(195): modules\\export->csv(Object(stdClass), 'myexport', NULL)\n#1 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/lib\/App.php(159): lib\\App->execSteps(Object(stdClass))\n#2 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/lib\/App.php(127): lib\\App->execSteps(Array)\n#3 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/lib\/App.php(116): lib\\App->exec(Object(stdClass), false)\n#4 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnectLib\/lib\/App.php(94): lib\\App->exec(Object(stdClass))\n#5 \/Users\/developer\/Sites\/localhost\/trainings\/dmxConnect\/api\/trainingformonly.php(8): lib\\App->define(Object(stdClass))\n#6 {main}"}

As i explained you already in your other topic - the Export Data expressions selected in your export action is WRONG.
It must be the query itself, look at my screenshot i posted already:


Not sure why not just follow what i already explained and instead you just try to complicate things with some random stuff put in the export data input …

Here is why I looked at your explanation and did not see the KEY.

In other applications in my rather lengthy experience you could take a query for 20 fields, for instance, from a table with multiple records and since the Query has connected and pulled up those fields not by " SELECT * FROM tablename" but by the best field-by-field Query "SELECT fieldone, fieldtwo, fieldthree FROM tablename " that following in the CSV export you specified which of those fields you wanted in this particular CSV export.

The CSV export could also allow the Developer to change the column order so that fieldthree results could be the first CSV rendered export to match a client"s request.

Then you could use the same query over and over, just changing which fields and their order the CSV would write

When I saw that the Dynamic Data picker allowed picking individual fields I thought Wappler"s Export CSV was understanding that the query.this_field, query.that_field instruction would only export fields chosen.

I did not know that I will have to write a separate API with its specific query to match for each CSV record to be exported.

Sorry i don’t really understand your last post.
The CSV module exports whatever data you output to it from your query. If you output 4 columns, this will be exported, if you output 10 columns, then 10 columns will be exported …

1 Like

This is not necessary. You will need a query for each but you could easily use conditionals looking at the value of a parameter to select which query to use while having the same export step afterwards. Just make sure the name is the same for each query so that it is passed to the export CSV.

Setting this up in a library action where you pass the relevant array to be exported would also work well.

1 Like

You don"t understand me because I was referring to other CSV export solutions.

One query can be used over and over to select all columns and then the CSV file only writes the column outputs specified in the CSV output order.

As you verify now each query must only specify exactly the column outputs needed for the CSV export file.

So “generic queries” don’t work as the starting point for the CSV export.

I’ve written php CSV export instructions that used one query but only output the columns I wanted into the CSV file.

The exciting thing for me is that a big problem has given me or explicit knowledge! :grinning:

Are you displaying the results in a table on the page? If so, you could use DataTables:

These have the ability to reorder columns, filter results etc. while also providing lots of export options

You are exactly correct, @bpj

But now I know how Wappler does its thing.

As far as creating a Client dashboard where they want different exports they can import into Excel all my sql query experience will come in handy.

I now know what Wappler wants here.

I didn"t have time to do the DataTables integration into Wappler but later I probably will.

Thank you!

It doesn’t take long (depending on how complex you want the DataTables options to be) - integration can be achieved in less than 5 mins (add cdn links to header, add JS from attached post, trigger upon Server Connect success)

1 Like

That is useful, indeed.

Now that I can do something without producing errors I’m happy to move forward!

@Teodor is like an octopus on the forum, 8 arms & hands hitting the keyboard like a maniac!
Many thanks to him.

I used DataTables a few years back in a php mysql environment.

How are they working in a node project?

Exactly the same as any other server type @NewMedia. They work fine with no problems.

1 Like

Exactly the same - they are a client-side library so it is irrelevant what server type you run. The scripts are added to the page HTML, JS added/linked to page. Configuring the ‘dom’ option (in the options JSON that you pass to the DataTable) can initialise most items, using default options, really quickly.

You can, if you want configure the hell out of it too - the searchBuilder extension adds enormous power to the user (making their own query to filter the table data), definitely one to look for

2 Likes

Row and Column re-order too @bpj, and State Save, all fine additions!

1 Like

@Teodor The csv export file is a thing of Exquisite Beauty !

Вы, сэр, стоите каждого рубля, который я зарабатываю, работая заправщиком на бензоколонке, заливающим бензин в путинский лимузин.

Haha, while i understand a bit of russian, it’s not my native language :slight_smile:

1 Like

Вие, господине, струвате всеки лев, който ми плащат, докато работя в станцията на Шел и помпам бензин.

Vie, gospodine, struvate vseki lev, koĭto mi plashtat, dokato rabotya v stantsiyata na Shel i pompam benzin.

Seems google translate became really good at translating to Bulgarian :slight_smile:

It took me a few minutes of correcting Google’s Bulgarian for minor mistakes, . . .

My Bulgarian girlfriend, Gergana, was visiting her parents and out of touch.
My Russian girlfriend, Larisa, tried to help but was a bit confused.

1 Like