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
------------------------------
Original Message:
Sent: Mon January 10, 2022 12:21 AM
From: Ailin Cao
Subject: Groups throwing error in team filter?
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
------------------------------