Is there any way to bulk extract of attachment of all items ?

Please let me know if there any way to bulk extract of attachment of all items

Add Comment
3 Answer(s)

If you have limited number of Items, you can use “Export” feature with a custom filter to include Attachment. This can export files from all those items. You use the same approach to download attached files from BOM Components as well. This will work fine if the list is limited. If your list of items is huge, you can think of SDK Code to fetch those attachments.

Agile Angel Answered on September 17, 2018.
Add Comment

Hi John,

What’s your business case for this. Generally bulk-attachments extract comes in picture when we are trying to copy attachments from old to new Manufacturer parts.

Generally i format an advance search and extract the documents using PDX package. This PDX gives the zip file which you can extract to get all your attachment.  The timing varies based on the count of your files.

Regards,
Arif

Agile Angel Answered on September 17, 2018.

Hi Arif,

Thanks for your suggestion. I used this and it helped me a lot.

But for some items it is not downloading the attachments and for some it does.

For some items it is not including the attachments eventhough I checked the attachment files.

Do you have any idea ?

Thanks.
John

on September 20, 2018.
Add Comment

I had to write a “report” + attachments converted into PDF file for a given item(s) and faced a problem where the user did not have rights to access some child items in the BOM… solved it using a new role to use for the PX.

Here is a sample code that you can run in SDK mode and expand for your own use:
The sample assumes that you have identified at least one attachment exists: ( no exception catching listed for simpler view )

ITable attachmentTable = (ITable) item.getTable(ItemConstants.TABLE_ATTACHMENTS);
Iterator<?> i = attachmentTable.iterator();
                
byte[] buffer = new byte[BUFFER_SIZE];
InputStream iStream = null;
FileOutputStream fos = null;    
                            
while( i.hasNext()) {
    IAttachmentRow row = (IAttachmentRow) i.next();
    String fileName = row.getCell(ItemConstants.ATT_ATTACHMENTS_FILE_NAME).toString();
                    
    if( shouldDownload(fileName)) {
                        
        String downloadFileName = getAbsLocationToDownload(fileName);
                                
        iStream = row.getFile();
                        
        if( iStream != null) {
    
            fos = new FileOutputStream(downloadFileName);
            int len = iStream.read(buffer);
            while( len != -1) {
                fos.write(buffer,0,len);
                len = iStream.read(buffer);
            }
            fos.close();
            fos = null;
                            
            // have a map to keep track of file name => downloaded location
            iStream.close();
            iStream = null;
                            
        }        
    }
}

Agile Talent Answered on March 27, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.