Skip to Content
0
Former Member
Jul 15, 2015 at 10:42 AM

how to delete all collaborators from ma using beanshell?

18 Views

hi,

i'm doing something like this:

// remove all collaborators
collaborators = doc.getCollaborators();
collabIter = collaborators.iterator();
while (collabIter.hasNext()){
    CollaboratorIBeanIfc collab = collabIter.next();
 hashValue= collab.getCollaboratorType().hashCode();
 try {
  if ((!((hashValue == 2) && (collab.getCollaboratorRole().getDisplayName().contains(GROUP_ROLE)))) &&
   (!((hashValue == 1) && (collab.getCollaboratorRole().getDisplayName().contains(OWNER_ROLE))))) {
      collabIter.remove();
   }
 } catch(Exception e) { 
        e.printStackTrace();
  log.setMethod("main");
  log.setLogMessage(e.getMessage());
  Logger.debug(log);
 }   
}

i wish to delete all groups and users with a owner role when saving the master agreement.

this script is working well. i execute this code on master agreement lifecycle event "saved".

when i press the save button all collaborators are deleted, but when i press the done button they are all back in my master agreement.

i have also try to use collab.delete() instead of collabIter.remove() but the behaviour was the same...

what i'm doing wronge here?

thanks

Waldemar