Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
16 replies Latest Post - ‏2013-01-28T16:51:34Z by SystemAdmin
SystemAdmin
SystemAdmin
7615 Posts
ACCEPTED ANSWER

Pinned topic assigning users to the activity in BPM8

‏2013-01-23T17:52:33Z |
Hi
i have an activity. And i want to assign based on the value coming from other activity.
one activity is sending group name and other activity is sending user name.
So the activity which i am trying to assign i am using Assignment as custom but i am not able to do it for both(groups and users)
So we are thinking to create another same activity and assign as users.
Can anyone suggest me here how can i assign on same single activity based on groups as well as user name .
Updated on 2013-01-28T16:51:34Z at 2013-01-28T16:51:34Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7615 Posts
    ACCEPTED ANSWER

    Re: assigning users to the activity in BPM8

    ‏2013-01-23T19:24:24Z  in response to SystemAdmin
    I'll assume here that you somehow know if we are doing a user or group. Assuming that is the case then simply set a string variable to the correct value. Depending on the type you are routing to the correct value would be -

    
    tw.local.myFullAssignString= 
    "ROLE: "+tw.local.userSelectedRole;
    

    or
    
    tw.local.myFullAssignString= 
    "PG: "+tw.local.userSelectedParticipantGroup
    

    or
    
    tw.local.myFullAssignString= 
    "USER: "+tw.local.userSelectedUser
    


    Obviously I used "tw.local.userSelected…." in order to be clear on how to use these. Your actual code would only need to have one variable for that. You would then use tw.local.myFullAssignString is the value for the custom routing. Technically you don't need the "USER:" added to the string when routing to a user, but I like to put it in to keep everything very clear.

    Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
    • SystemAdmin
      SystemAdmin
      7615 Posts
      ACCEPTED ANSWER

      Re: assigning users to the activity in BPM8

      ‏2013-01-24T06:08:52Z  in response to SystemAdmin
      Hi
      this is understanding what i got
      i have to create 2 variable
      1 variable : myFullAssignString or any variable(string type)
      2 variable : AssignName(string type)
      AssignName can have the value of groupname or user/particant name
      SO i will have to assign like
      tw.local.myFullAssignString = tw.local.AssignName;

      in the lane i have assigned the group:TestGroup
      TestGroup has below info:
      group1
      user:user1,user2
      group2
      user:user3,user4

      so when AssignName is group name e.g. group1:all users should be assigned
      and when AssignName is username e.g. user1 :then user1 will be assigned
      • SystemAdmin
        SystemAdmin
        7615 Posts
        ACCEPTED ANSWER

        Re: assigning users to the activity in BPM8

        ‏2013-01-24T17:10:54Z  in response to SystemAdmin
        The important thing to understand is that the system is doing some parsing on the string that you pass in. If you want to give the custom routing a user you can just give the user name. If you want to give it a security group you need to prepend the string "ROLE: " to the group name so that it knows how to lookup the right thing. Likewise if you want to route to a participant group you need to prepend "PG: " to the group name so the lookup will do the right thing.

        If you give just a group name without one of these special strings prepended to the group name, the system will assume you are trying to route to a user. The lookup of the user will fail and the BPD will fail.

        Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
        • SystemAdmin
          SystemAdmin
          7615 Posts
          ACCEPTED ANSWER

          Re: assigning users to the activity in BPM8

          ‏2013-01-25T09:36:19Z  in response to SystemAdmin
          Hi
          Then How can i assign depending upon the output, as output can be a user or can be a group.
          So what exactly i have to write in the custom assignment to satisfy my both condition.
          • SystemAdmin
            SystemAdmin
            7615 Posts
            ACCEPTED ANSWER

            Re: assigning users to the activity in BPM8

            ‏2013-01-25T15:42:41Z  in response to SystemAdmin
            I no longer understand your question. You as the developer need to have the ability to determine if the thing the user picked was a role or a person. If you can't do that then there is no way to solve this problem. Given that you have not told us any details on how the group or user is being selected, I cannot tell you how to solve that problem. If there is really no way to know based on the user selection, then you could write a service that took the routing value and used the JS API to see if represented a valid user name, role name, or participant group.

            Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
            • SystemAdmin
              SystemAdmin
              7615 Posts
              ACCEPTED ANSWER

              Re: assigning users to the activity in BPM8

              ‏2013-01-26T14:02:43Z  in response to SystemAdmin
              Hi

              Lets Say we have 3 activity
              Activity A---Output is Group Name
              Activity B--Output is User Name
              Both the Output is going to the input of Activity C . But only one will go either Group Name or User Name

              So For Lane of Activity C : what shuld i write which will fulfill both the criteria.
              right now we have created 2 activity just the duplication of Activity C :
              One for Group Name and other for User Name.
              So please suggest me anything to prevent this duplication here of same activity.

              Can we not write in custom(Assignment)something like
              if groupName != null
              then tw.local.grpName= "PG:"+tw.local.GroupName;
              else
              tw.local.userName = "User:+tw.local.UserName
              You got my question .Plaese suggest me here.
              • SystemAdmin
                SystemAdmin
                7615 Posts
                ACCEPTED ANSWER

                Re: assigning users to the activity in BPM8

                ‏2013-01-26T20:28:02Z  in response to SystemAdmin
                I'm still struggling to understand your question as well. What do you mean by "Both the Output is going to the input of Activity C ."? Are these sequential or not? I also don't understand "2 activity just the duplication of Activity C ".

                But, unless I'm mistaken, the answer is exactly what Andrew said. You are basically describing a rule. Which, more or less is essentially an activity that will take place prior to Activity C. You could write that activity as a rule service, a simple javascript service, or even a pre-activity assignment. (Although I recommend against using a Pre.) Something as simple as you write might be best as a Javascript implemented service, although it wouldn't take much additional logic to convince me to write a rule service.

                So you have activity A with an output of tw.local.groupName, Activity B with an output of tw.local.userName, Activity RoutingRule with an output of tw.local.activityCrouting, and Activity C with a custom routing with the value of tw.local.activityCrouting.

                Now, someone might point out that yes, you could do a single trinary conditional statement within the custom routing. But I'd discourage that. It makes the assignment too hard to understand. Not only will it make the assignment too long to easily inspect, but having an actual string containing the final assignment will make debugging and tracking easier.

                David
                • SystemAdmin
                  SystemAdmin
                  7615 Posts
                  ACCEPTED ANSWER

                  Re: assigning users to the activity in BPM8

                  ‏2013-01-27T14:45:54Z  in response to SystemAdmin
                  Hi David,
                  I didnot understand your question fully. Can you please ellaborate little more.
                  For my understanding what i got is that --- that you are asking me to create an Activity RoutingRule . The input will be from Activity A and Activity B. And the output of Activity RoutingRule will go to Activity C.
                  But i didnt get what exactly will have in the Activity RoutingRule.Lets say the output of Activity RoutingRule will be some string activityCrouting.So this string activityCrouting can be groupname or UserName.
                  So in the custom routing of Activity C will have tw.loacal.activityCrouting.
                  But if i write tw.loacal.activityCrouting, this will always tries to find userName.As for differentiating GroupName and UserName we have append User: and PG: for user and Group respectively.
                  So can you please point me correctly.
                  • SystemAdmin
                    SystemAdmin
                    7615 Posts
                    ACCEPTED ANSWER

                    Re: assigning users to the activity in BPM8

                    ‏2013-01-28T14:33:33Z  in response to SystemAdmin
                    Let me see if I can restate what David was saying. This isn't the only way to solve this, but perhaps we can at least get you to working and then disucss the miriad of alternatives for implementation if needed later.

                    So right now your diagram bascially can be summarized as follows -

                    "I have decision gateway. Based on this gatway my flow will either be to Task A or Task B. Both tasks go to Task C as the next step. Task A always returns a username for routing task C. Task B always returns a Group for the routing of Task C. How can I accomidate both routing types without having to put C in the diagram twice?"

                    Okay, so option A - This assumes that they actually set differnent variables on the BPD. Add a system lane activity "C Prime" this will, for purposes of clarity be a system service that takes the user and group variables, and returns one variable "routeToUse". In that service you just have one JS block -
                    
                    
                    
                    if(tw.local.userRouting == 
                    
                    null || tw.local.userRouting==
                    "")
                    { tw.local.routeToUse = 
                    "ROLE: "+tw.local.roleRouting; 
                    }
                    
                    else
                    { tw.local.routeToUse = 
                    "USER: "tw.local.userRouting; 
                    }
                    


                    Insert this activity before your activity C and you are done. Note this could also be handled by a JS at the BPD level.

                    I'll write up some other options later, but this is the most straight forward I can think of.

                    Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
                    • SystemAdmin
                      SystemAdmin
                      7615 Posts
                      ACCEPTED ANSWER

                      Re: assigning users to the activity in BPM8

                      ‏2013-01-28T14:35:46Z  in response to SystemAdmin
                      So, next option - have only one routing variable at the BPD level. Use it as the variable to recieve the seletion from both A and B. In B alter your code so that the string returned isn't just the role name but rather the string "ROLE: "+the value the user selected. Now you can just use the routing variable at the BPD level for C, since it is appropriate for either scenario.

                      Andrew Paier | Director of Special Operations | BP3 Global, Inc. www.bp-3.com
                • jmac_EmeriCon
                  jmac_EmeriCon
                  279 Posts
                  ACCEPTED ANSWER

                  Re: assigning users to the activity in BPM8

                  ‏2013-01-27T15:07:28Z  in response to SystemAdmin
                  David:

                  I don't want to muddy this thread, but I have a question regarding your discouraging using the "Pre & Post". Perhaps we can take this off-line, or maybe even a new thread.

                  Since there is a "visual cue" in the diagram, I do not see a reason why you would discourage this. Am I missing something? If this required enough logic to warrant a rule service, I get it, but in this case this could be a simple assignment in the "Post" of the previous activity (at least based on how I understand the requirement).

                  Thanks

                  John


                  _______________________________________________________________________

                  John McDonald

                  EmeriCon, LLC
  • SystemAdmin
    SystemAdmin
    7615 Posts
    ACCEPTED ANSWER

    Re: assigning users to the activity in BPM8

    ‏2013-01-27T08:40:51Z  in response to SystemAdmin
    I have attached the diagrams.
    Please refer the diagram Screen Shot1.
    In Condition if true then flow will go to Activity A and In Activity A some subflows is there and after executing Activity A , the output we get is GroupName, the flows goes to Activity C , there we have to assign to this GroupName which we received from Activity A.
    In condition if false then flow will go to Activity B and In Activity B some subflows is there and after executing Activity B , the output we get is UserName, the flows goes to Activity C , there we have to assign to this UserName which we received from Activity A.
    Now the Lane of Activity C ,it has all GroupName and UserName.
    So only one Activity(either Activity A or Activity B) will occur at one instance. So we can have GroupName or UserName as input to the Activity C. And We have to assign accordingly either to the Group or the User.
    So we are not sure how to implement both in single lane.

    Please refer to Screen Shot2 for what we are planning to do.
    We will have 2 separate Activity for Activity C , one will have all GroupName and other will have all userName.
    So when the flow come from Activity A , accordingly the flow will go.

    But we feel that this is not the good way to implement. We are using BPM8.
    I hope my questions are clear.
  • SystemAdmin
    SystemAdmin
    7615 Posts
    ACCEPTED ANSWER

    Re: assigning users to the activity in BPM8

    ‏2013-01-28T16:51:34Z  in response to SystemAdmin
    Hi
    Thanks everyone.
    i have implemented which you guys have suggested me. and I will share the solution which i have implemented.
    what i did is that in the activity A which in sending the groupName, i have written js in which i am doing something like tw.local.variable="PG:"+groupName and i am sending the variabe to the activity C and in the custom assignment i have written like tw.local.variable.
    Same thing i have done in Activity B like tw.local.variable="USER:"+userName and sending in the variable
    so this is solving my both for groupName and User.

    Please let me know if there is any better solution for this.
    Thanks everyone for helping me out.