cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

WTUser from a String

ScottKeller
1-Newbie

WTUser from a String

I am using the following code to get signatures from a set of workflow tasks:

wt.fc.QueryResult qr = wt.workflow.work.WorkflowHelper.service.getWorkItems(primaryBusinessObject);
java.lang.String current_signature = ";

if (qr != null)
{
while (qr.hasMoreElements())
{
WorkItem workitem = (WorkItem)qr.nextElement();
current_signature = workitem.getCompletedBy();

My problem is that the signature it returns is a string with the user name and not the full name. If I can turn the string into WTUser, I can then use getFullName() to get the full name of the user. Anybody have any ideas? Thanks in advance.

2 REPLIES 2

Hi

One can use the following



WTPrincipal wtprincipal1 =
OrganizationServicesMgr.getPrincipal(workitem.getCompletedBy());
if(wtprincipal instanceof WTUser)
String s1 = WTPrincipalUtil.getFullName((WTUser)wtprincipal);



Hope this helps



Thank you and have a great time.

Best Regards

Swamy Senthil

973 216 0456(M)

866 908 6561(F)

Swasen Inc

www.swasen.com

_____

You may want to use the WfVotingEventObject instead to get a record of completed workitems scroll to the bottom of my posting to see that code.

I have posted this code on ptcuser before. This is a safer way to find a wtuser object given the user id string:

Try the following:

try {

wt.util.WTProperties wtPropertiesReference;

wtPropertiesReference = wt.util.WTProperties.getLocalProperties();


String ldapServicesArray = new String[] {
wtPropertiesReference.getProperty("wt.federation.org.defaultAdapter")};

String[] ldapSubtreeScope =
{wt.org.OrganizationServicesHelper.SUBTREE_SCOPE};

wt.org.GenericDirectoryContextProvider directoryContextProvider = new
wt.org.GenericDirectoryContextProvider( ldapServicesArray, ldapSubtreeScope
);

wt.org.WTUser userVariableDefinedInWorkflow =
wt.org.OrganizationServicesHelper.manager.getUser(<usernamestringvariableinw<br/>orkflow>,directoryContextProvider);

} catch (Exception error)

{

error.printStackTrace();

}

Here is the wfvotingeventaudit logic to get full nameof completed by

WTCollection voting = WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)self.getObject(), null, null, null);
Object anItem = null;
wt.workflow.engine.WfVotingEventAudit aVote = null;
if (voting != null && !voting.isEmpty())
{
Iterator voteIterator = voting.iterator();

while (voteIterator.hasNext())
{
anItem = voteIterator.next();

if (anItem instanceof wt.workflow.engine.WfVotingEventAudit)
{
aVote = (wt.workflow.engine.WfVotingEventAudit)anItem;

// aVote.getUserComment()
// aVote.getActivityName()
// Role arole = aVote.getRole()
// aVote.isSigned()
// aVote.isRequired()
// aVote.getAssigneeRef() // returns WTPrincipalReference (who was assigned activty/workitem vote attached to)
// aVote.getUserRef() // WTPrincipalReference of voted/completed by
// aVote.getActivityKey() // long for querying for WfActivity object in all likelyhood
// aVote.getCreateTimestamp()
// aVote.getModifyTimestamp()
// aVote.getTimestamp()
// aVote.getTripCount() // numbe rof times activity been completed (not sure if in total or by a particular user)

}

}
}


Top Tags