I need to attach an attachment while the case is not persisted into db as it is temporary work object. Is there any possibility to add multiple attachments when it is temporary work object. ?
Temporary work object with attachments
Sharing
you can use pxFileUpload control. You can check some OOTB implementations of this control. When using this control you need to create one section that has a control that executes 'PopupFileBrowser(ev)' function and an activity like @baseclass.pzUploadFile. The files selected this way are uploaded to the file system but not yet saved in the database. pzUploadFile activity keeps uploaded file information in Primary.pyUploadedFile clipboard page of class Data-WorkAttach-File. When you create an actual case, you can use this pyUploadedFile page and attach a file to the case using one of the OOTB attachment activities which should be as simple as ->
Obj-Save pyUploadedFile
Call Work-.pxLinkAttachmentToCase
Mukkram
That's a great thought. But this perfectly fits when we say we need to attach only one file to a temporary work object. But what if we need to attach multiple files? pyUploadedFile property will be overwritten in this case.
@Superman
This is not straight forward since we know that temporary work objects will not have pzInsKey & pzInsKey of the work object is required in the Data-WorkAttach-* table to save the attachments.
Please give a try using the below approach and let us know of any issues.
1) Use OOTB section pzDragDocument to upload files in temporary work objects. This section will form a page list dragDropFileUpload in the current thread of class Embed-DragDropFile. This page list will have the information about the uploaded file like File Name, File stream, attachment type, etc.
2) Now create a custom page list property of Embed-DragDropFile class and have it under the work page. Copy the results from the step 1 list to our custom page list property for each upload.
3) Now when you persist the work object, loop through the page list property under pyWorkPage and invoke logic to attach those to the work object.
You can refer to our another discussion to understand how to attach a document to a work object.