07-26-2017 05:18 PM
I am attempting to work with files that have been attached in a form. How would I go about retrieving information within a JavaScript Script task? When I do a /activiti-app/api/enterprise/process-instances/${process_instance_id} call, I see that my variable for the attachment field = null, even when I have attached a document there.
I'm aware there is a relatedContentService, which requires some dependencies. Is there any way to check information (ANY information) on an attachment without leaving the BPMN editor?
Thank you
07-27-2017 03:17 AM
Greer Banks you need to use bpm_package in this way:
<code> var documents = bpm_package.children; </code>
Then you can loop through it to get those documents.
07-27-2017 10:12 AM
So I would still need to loop through the documents without being able to use it's ID from the form field? Because I can perform an api call to do the same thing, the issue is that documents are coming in in different orders based on what is attached.
07-28-2017 03:42 AM
07-28-2017 11:00 AM
What would I do then in the Alfresco Process Services runtime?
07-29-2017 07:51 AM
I am currently on vacation without access to the sources of the Alfresco Process Services project I am working on for one of my customers, so I cannot check if/how we dealt with that within scripts. I'd have to check how it is possible to access the Spring application context from withiin a script - with that you could access every Java services from scripts. I do this within Alfresco Content Services all the time and it's quite easy there via some static utilities, but have not had the need to do this with Process Services yet.
Last time I had to deal with related content (~4 weeks ago), I opted to write a Java-backed delegate since my delegate was intended to be reused in many process definitions (scripts or specifically script management in Process Services sucks with regards to reuse + testability).
07-31-2017 10:07 AM
When/if you are able, could you please provide an example where you were able to perform something like this within a Process Services script/listener? Thank you for your insight, Axel.
07-28-2017 03:46 AM
yes you have to still loop through. Even in the bpm_package the order is not necessarily as attached by the users. I do not think you can use the document IDs from the form field directly in a workflow start page without having started the process. As the process goes, the documents attached are still "soft-links" and have no relation yet with the process at that stage; only when the process has successfully started do the documents have the workflow metadata attached to them.
Hope this explanation is helpful.
Happy coding.
07-28-2017 11:00 AM
The process would have been started by then. How can I access the metadata of the attachment form fields within a JavaScript?
Explore our Alfresco products with the links below. Use labels to filter content by product module.