I created a String variable in my workflow called "User" (see the image below), now I want to get the name of the user, and assign it to the variable. I dont know how to do that in the expression. I really dont know the expression to get the user name, How would the line code be?
I need to do the same thing with the User group, I created a variable String called "group" and I want to get the user group name and assign it to the variable (group)
With the variable name "user" then it should simply be:
user = (wt.doc.WTDocument)primaryBusinessObject.getCreator();
You can use the Syntax button in your first screenshot above to check if you got a valid expression.
(I'm not able to syntax check what I wrote above - so it's just written from memory)
Sorry, I'm not sure which user group you mean, a user can be a member of several groups so you have to guide me on what Windchill group object you are referring to ...
Sorry I didnt explain my case.This is what I did:
1.- I created some users, using the "Participant Administration" form.
2.- Then I created some groups and assigned the users to a group.
Now in my workflow template I want to get the name of the group of the user and the name of the user too. So I declared a robot expression called "Get_User_Name" and I wrote the code line as the image below shows and I get the following error.
I hope you can help me.
2 issues in your code.
1 : The parenthesis. No cast in this case
2 : getCreator() returns a WTPrincipalReference, not a String, so :
user = ((wt.doc.WTDocument)pimaryBusinessObject).getCreator().getDisplayName();