0 votes
90 views
in Javascript API by (220 points)
Hello all,

I am using IBM BPM 7.5.2 version I have one observation while using participantGroups,

When user login time we fetch user role from LDAP using participantGroups.. This group having around 1500 users with different roles.

here i am sharing example

var myPG1= tw.system.org.findParticipantGroupByName("role1");

var allUsers = role1.allUsers;

for (var i=0; i<allUsers.length; i++)

{    log.info(allUsers[i].name);
}

for this approach it takes more than 2 mintues of time due to this performance got impacted.

Please suggest any better approach other than allUsers method to get length,name details.

2 Answers

0 votes
by (11.2k points)

I see that you have a typo in your code

var myPG1= tw.system.org.findParticipantGroupByName("role1");
myPG1.refresh();

var allUsers = myPG1.allUsers;

for (var i=0; i<allUsers.length; i++)

{    log.info(allUsers[i].name);
}

try a refresh once and time the individual steps which one is taking long time findPG or .allUsers also time the refresh also, idea being you may need to call refresh only once and caching should happen after that, I remember we had a situation where calling the refresh on a scheduled basis though a timer UCA helped.

0 votes
by (2.3k points)
My first question would be why you are doing this manually as group refresh is one of the actions that happens upon valid login of the user as part of the what the product simply does for you, so iterating over the users doesn't seem to server a purpose.

The second thing I would note is that due to the nature of the JS engine destructively processing large arrays shows significant performance gains over the use of iterators, assuming you don't need the array after processing is done.  So if you change your for loop to -

while(allUsers.length>0){

  log.info(allUsers[0].name);

  allUsers.delete(0);

}

for large arrays is will run faster.  (check the syntax though, can't remember if the exact call to remove an item from an array.

Related questions

0 votes
0 answers 268 views
0 votes
0 answers 27 views
0 votes
0 answers 52 views
0 votes
1 answer 43 views
0 votes
1 answer 60 views
0 votes
1 answer 228 views
0 votes
1 answer 25 views
0 votes
0 answers 15 views
0 votes
1 answer 23 views
0 votes
1 answer 35 views
0 votes
1 answer 59 views

495 questions

405 answers

81 comments

1.6k users

Created By Dosvak LLC (WWW.DOSVAK.COM)
Our Public Git Repository

Dosvak UI Toolkit --- Download --- Demo

Subscribe us at

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
...