How can i retrieve the document object id from the workitem

746 Views Asked by At

I got a requirement to retrieve the document object id(content engine doc id) from the workitem retrieved from process engine. And we obtain the document id we need to extract the corresponding document from content engine. I have created PE session and retrieved the workobject by using queuequery. I dont know how to proceed further.Is there any api code available for this?

3

There are 3 best solutions below

0
On

You can get the current version of the document from the version series and get that document's ID.

vs = Factory.VersionSeries.fetchInstance(objectStore, attachment.getId(), pf);
Id iDoc = ((Containable) vs.get_CurrentVersion()).get_Id();
0
On

Use the below method to get doc id from version series id from vwattachment.

VersionSeries versionSeries = (VersionSeries)objectStore.getObject("VERSIONSERIES", "versionseriesid");    
Property pp= versionSeries.fetchProperty("CurrentVersion", null);
System.out.println(pp.getIdValue());
Document doc = Factory.Document.fetchInstance(objectStore, pp.getIdValue(),null );
System.out.println("document is "+doc.get_Name());
4
On

I'm not 100% sure exactly what you're asking, but WorkItems do not have Document Ids. A WorkItem's unique identifier is a "WorkObjectNumber". To retrieve that, you can execute

VWQueueElement.getWorkObjectNumber()

If you are looking to retrieve the document Id of the attachment for a WorkItem, that is different. And you can retrieve that with the following

String attachmentName; // Set to name of attachment property used in Workflow
VWQueueQuery results = queue.createQuery(indexName, firstValues, lastValues, queryFlags, queryFilter, substitutionVars, VWFetchType.FETCH_TYPE_QUEUE_ELEMENT);
if(results != null)
{
    while(results.hasNext())
    {
        VWQueueElement e = (VWQueueElement) results.next();
        VWAttachment attachment = (VWAttachment) e.fetchWorkObject(false, false).getDataField(attachmentName).getValue();
        System.out.println(attachment.getId()); // Version Series Id
        System.out.println(attachment.getLibraryName()); // ObjectStore Name 
        System.out.println(attachment.getAttachmentDescription()); // Document Id 
        System.out.println(attachment.getAttachmentName()); // Attachment Name
    }
}