I want to save dataset in csv file. I using store procedure to get data and then creating file and writing data in that file. Below code creates file but does not write any data. Any suggestion where I went wrong.
var maxRow=10000
var dataset=plugins.rawSQL.executeStoredProcedure('<servername>',exportDataProcedure,args,typeargs,maxRow)
//elements.displayTestData.text='<html>' + dataset.getAsHTML() + '</html>' //dataset retrieves data by executing stored procedure
var csv = dataset.getAsText(',','\n','"',true)
//Show a save open dialog and retrieve the file
var file = plugins.file.showFileSaveDialog('export.csv');
var success = plugins.file.writeTXTFile(file,csv); // Throws warning : "The function writeTXTFile(String,String) is not applicable for the arguments( ?,String)"
warning is probably just a ‘buildmarker’.
It is basically telling you that the function won’t work for the type of arguments.
In this case, I’d say Servoy is not recognizing the ‘var file’ as being as JSFile type.
You can try and solve this by adding:
/** @type{plugins.file.JSFile} */
This should be added right above the declaration of the ‘file’ variable.
But this is all stuff which isn’t solving your actual problem.
The most probable cause of not seeing any data in your file is your dataset not containing any data.
Did you check on that? Maybe debug or add a console output to your code: