0 votes
761 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 (21.5k 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
1 answer 390 views
+1 vote
0 answers 1.2k views
0 votes
0 answers 240 views
0 votes
0 answers 704 views
0 votes
1 answer 240 views
0 votes
1 answer 561 views
0 votes
1 answer 751 views
0 votes
1 answer 505 views
0 votes
0 answers 136 views
0 votes
1 answer 449 views

634 questions

495 answers

97 comments

2.7k users

Join BPM Community Discord Channel

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.
Created by Dosvak LLC
Our Youtube Channel
...