Hi Experts,
I have a class extending from runbase (cannot replace with sysoperation due to internal reasons) .
Facing 2 issues with this class, please suggest a fix
1. How can i ensure that when use browse to select a file it only shows *.CSV files in the browse window. LINE 23 in below code
2. Code runs without issue when running in non batch mode with Run on property set to "Called from or Client" , however
when running in batch it keep throwing the error "No file selected " even when a file is selected. LINE97 in below code for same run on properties.
We cannot change the class run on to server as the end users will be browsing & selecting a file from their local system & not server or network share.
Shared below is the code & I have followed this pack /unpack using this MSFT link
class myClass extends RunBaseBatch { CommaIo csvFile; Filename filename; DialogField dialogFilename; #define.CurrentVersion(2) #define.Version1(1) #localmacro.CurrentList filename #endmacro #File protected Object dialog() { DialogRunbase dialog = super(); ; dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen)); dialogFilename.value(filename); dialog.filenameLookupFilter(["All files", #Allfiles]+#csv]); // HOW TO ENSURE ONLY CSV SHOWS UP return dialog; } public boolean getFromDialog() { filename = dialogFilename.value(); return super(); } public container pack() { return [#CurrentVersion,#CurrentList]; } public void run() { try { this.vendUpdate(); } catch (Exception::UpdateConflict) { throw Exception::UpdateConflict; } } public boolean unpack(container packedClass) { int version = conPeek(packedClass,1); #localmacro.ListV1 #endmacro ; switch(version) { case #CurrentVersion: [version,#CurrentList] = packedClass; break; default: return false; } return true; } protected void vendUpdate() { TextBuffer textBuffer = new TextBuffer(); SysOperationProgress importProgress = new SysOperationProgress(); #AviFiles container dataCon; Io importFile; #file str Delimiter = ","; boolean firstRow = true; int totalNumOfRows,totalnumOfRecordRows; int counterNumOfRows = 1; str filePath,fileNameOnly; filename fileType; InteropPermission permission; permission = new InteropPermission(InteropKind::ClrInterop); importFile = new CommaTextIo(filename,#IO_Read); permission.assert(); [filePath, fileNameOnly, fileType] = fileNameSplit(filename); if((!importFile) || (importFile.status() != IO_Status::Ok)) throw error ("No file selected"); KEEPS throwing this error when running in batch. if(fileType != #csv) throw error ("Selected filetype is not *.csv"); if(fileNameOnly != 'UpdateVend') throw error ("Selected CSV file is not UpdateVend"); importFile.inFieldDelimiter(Delimiter); try { while(importFile.status() == IO_Status::Ok) { //main logic } } catch { } } }
Thanks
Mav