Get Work Item from Key Id (idA2A2)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Get Work Item from Key Id (idA2A2)
Hi,
I have used this case item
to get the work item records I want to complete through an API call.
And this case
https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS234435
tells you how to complete the work item once you have it.
But from the records I get through a SQL query, I have the unique key for the work item (idA2A2 from table WorkItem), but how do I get the WorkItem object in code from this unque key.
If I try a search condition such as
SearchCondition condition = new SearchCondition(WorkItem.class, WorkItem.IDENTITY, SearchCondition.EQUAL, iWorkItemId);
I get an error that says
Caused by: Attribute "identity" is not a member of class "class wt.workflow.work.WorkItem"
If I try
SearchCondition condition = new SearchCondition(WorkItem.class, "workitem.persistinfo.key.id", SearchCondition.EQUAL, iWorkItemId);
I get a similar error.
So what is the search condition for when you have the idA2A2 column (key Id column info). Surely there is a way of finding the object if you have the unique id (whether it be WTPart, WTDocument, WorkItem etc).
Is there a list somewhere of what the identity parameter for each object type should be (ie what the "workitem.persistinfo.key.id" should really be)?
Thanks
Ben
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks everybody for your responses. I have finally managed to solve it with your help. The code I have implemented is general and allows for getting quite a few object types if you have the idA2A2 unique Id
public static Persistable getObject(String paramString) throws WTException { if ((paramString == null) || (paramString.isEmpty())) { throw new RuntimeException("oid is null"); } WTReference localWTReference = getReference(paramString); if (localWTReference == null) { throw new WTException("Reference not found " + paramString); } return localWTReference.getObject(); } public static WTReference getReference(String paramString) throws WTException { if ((paramString == null) || (paramString.isEmpty())) { throw new RuntimeException("oid is null"); } int i = paramString.indexOf(126); paramString = paramString.substring(i + 1); ReferenceFactory referenceFactory = new ReferenceFactory(); return referenceFactory.getReference(paramString); }
I call the getObject for a Work Item by using this
public static WorkItem getWorkItemFromId(long iWorkItemId) throws WTException { WorkItem wi = (WorkItem)getObject("OR:wt.workflow.work.WorkItem:" + Long.toString(iWorkItemId)); return wi; }
If I want to get say a WTPart I would call it like this (and I've tested this)
public static WTPart getWTPartFromId(long iWTPartId) throws WTException { WTPart part = (WTPart)getObject("OR:wt.part.WTPart:" + Long.toString(iWTPartId)); return part; }
You can do similarly for other object types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Ben,
if you have the ida2a2 of the WorkItem object, you can get it with this code:
WorkItem myWorkItem = (WorkItem) new ReferenceFactory().getReference("wt.workflow.work.WorkItem:xxxxxxx").getObject();
where "xxxx" is the ida2a2 of the WorkItem object.
Regards
![]() | Iker Mendiola - Prambanan IT Services |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If you are using a query spec, you should use one of the valid colum names. You can info report to get the right column name. So the correct column name for ida2a2 is WorkItem.PERSIST_INFO + ".theObjectIdentifier.id"
qs.appendWhere(new SearchCondition(WorkItem.class, WorkItem.PERSIST_INFO + ".theObjectIdentifier.id", SearchCondition.EQUAL,Long.parseLong("12164431")), null);
if you are navigating from an activity you can directly use the service WfWorkflowStatusHelper.service.getWorkItems(act) to get all the work items.
asds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks everybody for your responses. I have finally managed to solve it with your help. The code I have implemented is general and allows for getting quite a few object types if you have the idA2A2 unique Id
public static Persistable getObject(String paramString) throws WTException { if ((paramString == null) || (paramString.isEmpty())) { throw new RuntimeException("oid is null"); } WTReference localWTReference = getReference(paramString); if (localWTReference == null) { throw new WTException("Reference not found " + paramString); } return localWTReference.getObject(); } public static WTReference getReference(String paramString) throws WTException { if ((paramString == null) || (paramString.isEmpty())) { throw new RuntimeException("oid is null"); } int i = paramString.indexOf(126); paramString = paramString.substring(i + 1); ReferenceFactory referenceFactory = new ReferenceFactory(); return referenceFactory.getReference(paramString); }
I call the getObject for a Work Item by using this
public static WorkItem getWorkItemFromId(long iWorkItemId) throws WTException { WorkItem wi = (WorkItem)getObject("OR:wt.workflow.work.WorkItem:" + Long.toString(iWorkItemId)); return wi; }
If I want to get say a WTPart I would call it like this (and I've tested this)
public static WTPart getWTPartFromId(long iWTPartId) throws WTException { WTPart part = (WTPart)getObject("OR:wt.part.WTPart:" + Long.toString(iWTPartId)); return part; }
You can do similarly for other object types
