- Maximo attachments upload and download attachemnts one at a time.
- There is no out of the Box option to select multiple attachments and download at once.
- Here is a way to achive this via cusom dialog and automation sctipt.
Add custom dialog:
- Modify or clone the View attachments dialog
- Add a checkbox in the dialog to select the documents.
Type: Event
Event: toggleselectrow
- Add a 'Download' custom action button at the footer of dialog.
- Create an action launch point for the button and write below code
from psdi.util import MXApplicationException;
from java.io import FileOutputStream;
from java.io import FileInputStream;
from java.nio.file import Paths;
from java.nio.file import Files;
from java.util.zip import ZipOutputStream;
from java.util.zip import ZipEntry;
from java.io import File;
if launchPoint=='<>':
session=service.webclientsession()
docTable=session.getDataBean("<dialog_id>")
docVector=docTable.getSelection()
filePaths=[]
for doc in docVector:
file=doc.getString("URLNAME")
filePaths.append(file)
downLoadPath="C:\\Users\\Public\\Downloads\\";
fullPath=downLoadPath+"<FileName>.zip";
fos = FileOutputStream(fullPath);
zipOut = ZipOutputStream(fos);
try:
for filePath in filePaths:
fileToZip = File(filePath);
fis = FileInputStream(fileToZip);
zipEntry = ZipEntry(fileToZip.getName());
zipOut.putNextEntry(zipEntry);
bytes = Files.readAllBytes(Paths.get(filePath));
zipOut.write(bytes, 0, len(bytes));
fis.close();
zipOut.close();
fos.close();
print ("Compressed the Files to " +str(fullPath));
except MXApplicationException as me:
print ("Maximo Error : " + str(e));
except Exception as e :
print ("Error : " + str(e));