BPM, Workflow, and Case

 View Only
  • 1.  Groups throwing error in team filter?

    Posted Mon January 10, 2022 12:21 AM
    We have a team filter service that was working until we added custom groups to the team. 

    Now it throws this error: CWTBG0019E: Unexpected exception during execution. Internal Script error: com.lombardisoftware.core.TeamWorksRuntimeException: com.lombardisoftware.core.TeamWorksException: Type mismatch. Expected "tw.object.String" type, but found "com.lombardisoftware.core.script.js.objects.UserScriptable" java class. Value: "com.lombardisoftware.core.script.js.objects.UserScriptable@3ec2daae" ".'.

    The code is standard team filtering from the BAW exercise book pg. 368:

    //copy the original team and then recreate the team members
    tw
    .local.filteredTeam = new tw.object.Team();
    tw.local.filteredTeam.name = tw.local.originalTeam.name;
    tw.local.filteredTeam.managerTeam = tw.local.originalTeam.managerTeam;

    tw.local.filteredTeam.members = new tw.object.listOf.String(); //iterate through original list
    for (var i = 0; i < tw.local.originalTeam.members.listLength; i++) {
    if (tw.system.org.findRoleByName(tw.local.originalTeam.members[i])) { //team
    var tempTeam = tw.system.org.findRoleByName(tw.local.originalTeam.members[i]).users;
    for (var j = 0; j < tempTeam.length; j++) {
    if (tempTeam[j].name != tw.local.hrAdmin1) {
    tw.local.filteredTeam.members[tw.local.filteredTeam.members.listLength] = tempTeam[j].name;
    }
    } else {
    //individual user
    if (tw.local.originalTeam.members[i] != tw.local.hrAdmin1)
    //if member is not the hrAdmin member, add member to filtered list;
    tw.local.filteredTeam.members[tw.local.filteredTeam.members.listLength] = tw.local.originalTeam.members[i].toString();
    }
    }

    This error does not happen when Teams are assigned to individuals only or when teams are assigned to tw groups.

    This error only happens when the team contains custom groups created in Process Admin Console. Custom groups consist of only individual users.

    Does anyone know what causes this?

    Thanks!

    ------------------------------
    Ailin Cao
    Associate Application Developer
    IBM
    ------------------------------


  • 2.  RE: Groups throwing error in team filter?

    IBM Champion
    Posted Tue January 11, 2022 01:10 AM
    Hi Ailin,

    I tried recreating your scenario but this piece of code works fine with a team containing a user and a group created through Process Admin consisting one user.
    I am not too sure about your configuration, it would be helpful to identify the issue if you can provide  - 

    1. Full error log including the line number where the error is occurring 
    2. Setup of the team, meaning the construction of the team

    My snippet (its exact same)
    tw.local.filteredTeam = new tw.object.Team();
    
    tw.local.filteredTeam.name = tw.local.originalTeam.name;
    tw.local.filteredTeam.managerTeam = tw.local.originalTeam.managerTeam; 
    tw.local.filteredTeam.members = new tw.object.listOf.String();
    
    for (var i = 0; i < tw.local.originalTeam.members.listLength; i++) {
        if (tw.system.org.findRoleByName(tw.local.originalTeam.members[i])) {
            var tempTeam = tw.system.org.findRoleByName(tw.local.originalTeam.members[i]).users;
            for (var j = 0; j < tempTeam.length; j++) {
                if (tempTeam[j].name != tw.local.hrAdmin1) {
                    tw.local.filteredTeam.members[tw.local.filteredTeam.members.listLength] = tempTeam[j].name;
                }
            }
        } else{
            if(tw.local.originalTeam.members[i] != tw.local.hrAdmin1){
                tw.local.filteredTeam.members[tw.local.filteredTeam.members.listLength] = tw.local.originalTeam.members[i].toString();
            }
        }
    }​



    ------------------------------
    Atanu Roy
    Solution Architect
    Salient Process
    ------------------------------



  • 3.  RE: Groups throwing error in team filter?

    Posted Mon March 07, 2022 11:23 AM
    Thanks Atanu for your help. I eventually discovered the error is in 

    var tempTeam = tw.system.org.findRoleByName(tw.local.originalTeam.members[i]).users;

    .users was not retrieving any users. I switched to .allUsers and it is working as expected. 

    Maybe the BAW training document should be updated to use .allUsers instead of .users.

    ------------------------------
    Ailin Cao
    Associate Application Developer
    IBM
    ------------------------------



  • 4.  RE: Groups throwing error in team filter?

    Posted Tue March 08, 2022 03:36 AM
    I think, the difference between users and allUsers is that the first is likely for the users in that groups, whereas allUsers also covers users of nested subgroups.
    https://www.ibm.com/docs/en/baw/20.x?topic=apis-javascript-api-in-processes-service-flows#TWRole

    ------------------------------
    Jens Engelke
    ------------------------------