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?
Asked
Active
Viewed 635 times
3 Answers
0
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
}
}

Matt F
- 46
- 1
-
Thanks for explanation. I am able to get the attachment object from which i can able to get the version series id and all parameters except document id for which i am using attachment.getAttachmentname. Its showing as null. Is there any other way to get the document id from this attachment object – Salman Sep 10 '19 at 12:26
-
You can attempt to use `attachment.getAttachmentDescription` – Matt F Sep 11 '19 at 13:02
-
I used attachment.getAttachmentDescription but i returned me null value. I don't know why.I found an alternative by using SearchScope to query the documentid from version series table with the version series id and it worked. Thanks for the response. – Salman Sep 14 '19 at 12:08
-
your version series id should be able to get you the document. If you want the actual document id, create a field in your workflow and set the id when launching it – bajji Dec 18 '19 at 06:38
0
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());

Ersoy
- 8,816
- 6
- 34
- 48

Ankit Mathur
- 1
- 1
0
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();