Hello all,
I've created a new class that exports CSV from selected records on the list page.
It's working fine when run on AX client, but when running the button from Enterprise Portal, it doesn't save the CSV file on the folder. No errors encountered.
Is there additional permissions needed? Below is my code:
client server public static void main(Args _args)
{
#File
#xppTexts
CommaIo file;
container line;
str filepath;
container confilter = ['.csv', '*.csv'];
CommaTextIo commaTextIo;
FileIOPermission permission;
tableA tableA;
Common multiSelectionRecord;
MultiSelectionContext multiSelectionContext;
TextBuffer textBuffer;
str fileName;
utcDateTime dateTime = DateTimeUtil::getSystemDateTime();
;
fileName = curUserId() + DateTimeUtil::toFormattedStr(dateTime, 231, DateDay::Digits2,
DateSeparator::None, DateMonth::Short, DateSeparator::None, DateYear::Digits4, TimeSeparator::Dot, TimeSeparator::Dot);
filepath = strFmt("C:\\temp\\%1.csv", filename);
new FileIOPermission(filepath, "rw").assert();
textBuffer = new TextBuffer();
//write header
textBuffer.appendText("Item Id");
multiSelectionContext = _args.multiSelectionContext();
if(multiSelectionContext)
{
multiSelectionRecord = multiSelectionContext.getFirst();
tableA = multiSelectionRecord;
while(tableA)
{
textBuffer.appendText(strFmt('%1', tableA.ItemId));
textBuffer.appendText(#newline);
tableA = multiSelectionContext.getNext();
}
}
textBuffer.toFile(filepath, FileEncoding::UTF8);
CodeAccessPermission::revertAssert();
}