Cancel
Showing results for 
Search instead for 
Did you mean: 

Filter WFs with Conditions - How to compare actual user with a dynamic participant

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hello everyone

 

I am filtering my Workflows with Conditions. I also use dynamic participants to assign users to workflow tasks.

 

I only want to able to start a workflow on an itemRevision if a dynamic participant $TestParticipant that was assigned to the itemRevsion is the same as the actual logged in user.

 

Any suggestions which expressions i need to use to accomplish that?

 

Thanks for your help!

 

 

 

7 REPLIES 7

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Siemens Phenom Siemens Phenom
Siemens Phenom

I've not tried this myself, but there is an operation fnd0IsParticipant defined on ItemRevision that looks like it matches your requirement;

 

000255.jpg

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Thanks for the reply jonathan

 

i tried to use the fnd0IsParticipant Operation but haven't been successful. My question on this is: What is meant by "participantTypeName". Is it the name of the Participant BusinessObject? 

I tried the following expression:

1.png2.png

 

In the meantime i tried another way, with a compound property that contain the user_id of my partipant which i can then compare with the UserSessions user_id, but i think this is only possible for one participant and not for many.

 

So i am still interested in finding a solution using fnd0IsParticipant.

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Siemens Phenom Siemens Phenom
Siemens Phenom

There are a few of the out of the box change conditions that use this operation.

In these examples it's the name of the participant type, so it looks like you are providing the correct argument.

I'll try it on a development system I have and see if I can get it working.

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi @BB_ .  I've tried this on a Teamcenter 11 (11.5.0.5(20181019.00)) 64-bit system as follows;

 

  • Create a participant type JM4_SingleUser.
  • Set its ParticipantAllowMultipleAssignee constant to false
  • Set its ParticipantUsedOnObjectTypes to ItemRevision
  • Set its ParticipantHandlerKeyword to SINGLE_USER (may not need this)

 

  • Create a condition JM4_WF_isSingleUser(ItemRevision o, ImanType t, UserSession u)
  • Set the condition expression to o.fnd0IsParticipant("JM4_SingleUser")

     

  • Create a participant type JM4_MultiUser.
  • Set its ParticipantAllowMultipleAssignee constant to true
  • Set its ParticipantUsedOnObjectTypes to ItemRevision
  • Set its ParticipantHandlerKeyword to MULTI_USER (may not need this)

 

  • Create a condition JM4_WF_isMultiUser(ItemRevision o, ImanType t, UserSession u)
  • Set the condition expression to o.fnd0IsParticipant("JM4_MultiUser")

 

  • Deploy the template.

 

  • Ensure the site preference WRKFLW_use_legacy_template_filter is false.
  • Ensure the site preference CR_allow_alternate_procedures isn't set to All.
  • In Workflow Designer create a couple of simple workflows (Single, and Multi) and assign the condition to each.

 

  • As a normal user create some items and assign participants to the ItemRevisions
  • Try and create a workflow process and see the assigned templates.

 

My results are as follows;

If I select a single ItemRevision...

  • The Single template is available if I am logged in as the user who is the JM4_SingleUser participant.
  • The Multi template is available if I am logged in as one of the users who is in the JM4_MultiUser participant.

If I select multiple ItemRevisions...

  • The Single template is available if I am logged in as the user who is the JM4_SingleUser participant on every selected ItemRevision.
  • The Multi template is available if I am logged in as one of the users who is in the JM4_MultiUser participant on every selected ItemRevision.

So for multiple ItemRevisions all of them must match the condition for the template to be available.

 

Note that the check is for the entire profile, not just the user id, so the login user, group, and role must match that specified in the participant.

If you only want a check for the user irrespective of their current group / role then this operation won't be suitable.

 

If that is what you want to do then you can get part of the way with a bit of BMIDE kung-fu.

  • Create a compound property on Participant;
    jm4_user_name as Participant.assignee / GroupMember.user_name
  • Create your condition with the same signature as before, but with the expression

    Function::INLIST(u.user_id, o.participants, "jm4_user_name")

The participants runtime property of ItemRevision gives you all the participants.  This expression compares the current users user_id with the compound property each of the participants, and returns true if it finds a match.

 

The caveats to this are;

  • You can't specify the participant type, it's checking for a membership against all the participant types.
  • It doesn't work if you specify a participant that isn't a user i.e. group or role in group.

 

If you want an equivalent of the current fnd0IsParticipant that only checks the user for validity then you'll probably need to reach for the C compiler, raise an ER, or both.

 

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Thank you for your affort jonathan!

 

That really helped me out. It is now working for me in the same way as it does for you. I have used Teamcenter 12 (12.0(20180710.00)) 64-Bit for testing by the way.

 

Especially the second way with the compound property is interesting even though one can't specify a participant there.

 

I was wondering if there is a way to place the compound property directly on a participant so that the Function::INLIST queries only this participant type and not all participants, but then i noticed that Function::INLIST only works for arrays of parameter type UNTYPED_REFERENCE (2nd parameter) - not all properties are array so this won't work.

 

Thanks again!

 

 

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Its me again

 

I have a new Use-Case that i try to solve and which seems to be even more difficult.

I don't want to assign a person as a participant now i want to assign a role for example "engineer" to a participant. So that all users that are in this role "engineer" can see a Workflow task in their Worklist.

 

The question is if there is any OOTB solution to compare if the logged in user (only user_id is nessesary) is assigned to that role in the organisation structure. (I think this one is even more difficult, because if you assign a role (resource pool) to a participant there is no comparable user_id)

 

If anyone has an idea, let me know.

 

Best regards

Re: Filter WFs with Conditions - How to compare actual user with a dynamic participant

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi again.

I think that fnd0IsParticipant doesn't help in this case as it doesn't seem to handle participants that don't resolve down to a given user.  i.e. wildcard user and role always return false.

That's probably worthy of an ER as it's the kind of thing companies want to do.

 

You may be able to get away with the compound property trick again.

You can compound Participant.fnd0AssigneeRole / Role.role_name to give you the name of the participant role.

UserSession already has a role_name compound for the logged in user role.

Your condition could be similar to before, but checking the role_name.