Announcements
Hi,
I'm using this code for Export CSV file through batch job but got the FileIOPermission error.
fileName = "\\sssdt-006\\ExportCSV\\" + "ItemDetails" + ".csv";
filepermission = new FileIoPermission(fileName, 'w');
commaIO = new CommaIO(fileName, 'r');
filepermission.assert();
q = new Query();
qbds = q.addDataSource(tablenum(InventTable));
qbr = qbds.addRange(fieldnum(InventTable,ItemId));
qr = new QueryRun(q);
commaIO.write("ItemId");
while (qr.next())
{
inventTable = qr.get(tablenum(InventTable));
commaIO.write(inventTable.ItemId);
commaIO.write(output);
}
CodeAccessPermission::revertAssert();
Thanks for the help in advance.
Hi Prabakaran,
So check the file permission or folder permission if user has access to it in write mode
Please invert the position of your code:
your code: filepermission = new FileIoPermission(fileName, 'w');
commaIO = new CommaIO(fileName, 'r');
filepermission.assert();
the correct code:
filepermission = new FileIoPermission(fileName, 'w');
filepermission.assert();
commaIO = new CommaIO(fileName, 'r');
You need to check if the user that your AOS runs under has access to the folder you are trying to write the file too.
Hi Mehdi,
Thank you for reply, I have used that.
Thank you
Have you put this code in a class that extends RunBaseBatch ?
Hi Mehdi,
Thank you for your response
This my code , this code take from above link,
Query q;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
QueryRun qr;
CommaIO commaIO;
FileName fileName;
InventTable inventTable;
;
fileName = "C:\\ExportFile\\" + "ItemDetails" + ".csv"; //Destination of the file
commaIO = new CommaIO(fileName,'W');
q = new Query();
qbds = q.addDataSource(tablenum(InventTable));
qbr = qbds.addRange(fieldnum(InventTable,ItemId)); //Range
qr = new QueryRun(q);
commaIO.write("ItemId","Item Type"); //Header of the CSV File
//Loop to insert values in the csv from the table
while( qr.next() )
{
inventTable = qr.get(tablenum(InventTable));
commaIO.write(inventTable.ItemId,enum2str(inventTable.ItemType));
}
WINAPI::shellExecute(fileName);
}
Thank you
Hi Prabakaran,
Coul you please send me your code ?
Thanks
Hi Mehdi
Thank you for reply your above link is working fine only for normal job and class but unfortunately its not work for batch job, i got same error, please suggest me some other solution to solve this.
Thank you
Hi Prabakaran
You could see tutorial below :
NB : If it resolve your problem please mark as answered :D
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148