Throws warning while Writing data to csv file

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)"

Any suggestiong why it throws warning.

Hi,

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:

application.output(dataset)

Hope this helps

Thanks Marc,

I added typo for JSFile and able write to dataset data in file. Is warning makes any difference that restricts to write dataset to file?

Where as dataset returned data and checked by displaying on form element.

elements.displayTestData.text='<html>' + dataset.getAsHTML() + '</html>' 

Anyways, it worked.

Glad it works.

hardina09:
Is warning makes any difference that restricts to write dataset to file?

No, warnings are in fact ‘buildmarkers’. They are there to help you write clean and working code, but are no restriction on executing code.

Got you. Thanks Marc for reply.