Expand my Community achievements bar.

Getting Attachments from a submitted form

Avatar

Level 3
Hi,

I'm looking for a way to get attachments out of a submitted xfaForm. I need to do some processing of these files but I can't seem to find a way to get at them. Any suggestions?



Thanks,

Rob V.



PS, I can't buy any custom components.
12 Replies

Avatar

Former Community Member
Are the attachments in the PDF or are they in the envelope of a taskmanager user step?

Avatar

Level 3
The envelope of the Task manager User Step.

Avatar

Level 10
You'll need to build a custom component or use the Script service to get the attachment at the very first step.



I'll try to come up with something.



Jasmin

Avatar

Level 10
Can you post the source (just paste the main class here if possible)?



Thanks,



Jasmin

Avatar

Former Community Member
here is the code - this gets the attachments out of task

private Context getUserContext(String aUserId)

{

ServiceClientFactory _factory;

Context _context = null;

try

{

Context _adminContext = UMLocalUtils.getSystemContext();

_factory = ServiceClientFactory.createInstance(_adminContext);

AuthenticationManagerServiceClient _am = new AuthenticationManagerServiceClient(_factory);

DirectoryManagerServiceClient _dm = new DirectoryManagerServiceClient(_factory);

Principal _pm = _dm.findPrincipal(aUserId);

if(_pm != null && _pm.getPrincipalType().contains(Principal.PRINCIPALTYPE_USER))

{

String _userName = _pm.getCanonicalName();

String _domain = _pm.getDomainName();

AuthResult _ar = _am.getAuthResultOnBehalfOfUser(_userName, _domain, _adminContext);

_context = new Context();

_context.initPrincipal(_ar);

}

} catch (Exception e)

{

}

return _context;

}

public java.util.List taskAttachments(long taskId) {

// TODO Auto-generated method stub

//ServiceClient myServiceClient = _Factory.getServiceClient();

List listOfDocuments = new ArrayList();

createServiceClientFactory();

System.out.println("The taskId is"+taskId);

try{

TaskManagerClientFactory tmClientFactory = new TaskManagerClientFactory();

TaskManager tm = TaskManagerClientFactory.getTaskManager(_Factory);

TaskInfo taskInfo = tm.getTaskInfo(taskId);

ParticipantInfo participant = taskInfo.getAssignedTo();

String taskUserId = participant.getSpecifiedUserId();

System.out.println("*** The task user id is "+taskUserId);

Context _context = getUserContext(taskUserId);

ServiceClientFactory _userFactory = ServiceClientFactory.createInstance(_context);

tm.setContext(_context);

AttachmentInfo attachInfo[] = (AttachmentInfo[])tm.getAllAttachments(taskId);

for(int i=0;i<attachInfo.length;i++)

{



System.out.println("****The file name is "+ attachInfo[i].getFileName());

Document doc = tm.readAttachmentDocument(taskId,attachInfo[i].getId());

listOfDocuments.add(i,doc);

System.out.println("****The isze of list is "+listOfDocuments.size());

}

return listOfDocuments;

}

catch(Exception e)

{

e.printStackTrace();

}

return null;







}

Avatar

Level 3
Hi,

How would I find the task id to pass to that? Is it the same as the ProcessID?



Thanks,

Rob V.

Avatar

Level 9
You can save the task-id in the Output section of the user component.

Getting at the task-id of the initial task is hard, you need to do a bunch of database queries.

Are you sure you can't you buy components, this would simplify things?

Howard

Avatar

Level 3
Yeah, we're unable to buy any components.

Avatar

Level 9
Hi Robert

I'm not trying to be pushy, but WHY can't you buy any components? It seems that you have a problem, and fixing it yourself is going to take a lot more effort (and end up costing a lot more money) than just buying a component that does the job. What am I missing?

Howard

Avatar

Former Community Member
(Was going to say you could use Assembler, but just realized I'd not read the thread from the beginning and see you're not getting this from a PDF nor XDP.)

Avatar

Former Community Member
when you open the form in workspace,and go to the TaskDetails form you will see the taskID