+ Start a Discussion
Balakumar Ramachandran 6Balakumar Ramachandran 6 

Multiselect picklist

i want to prevent values that are already loaded.. the userlist should not contain values that are already selected..how do i do it ?

public list<SelectOption> getLeftOptionList(){
    list<SelectOption> TempOptionList = new list<SelectOption>();
    list<User> TempValueList;
    list<User> UserList;

    list<PermissionSetAssignment> userpermission;
    map<id,PermissionSetAssignment> s = new map<id,PermissionSetAssignment>();
    userPermission =   [SELECT Assignee.Name, AssigneeId FROM PermissionSetAssignment where PermissionSet.id in ('0PSf0000000Cqcg','0PSf0000000CqZc')];
    system.debug('-------User Permission--------'+userPermission);
    for(PermissionSetAssignment p : userPermission)
    {
       s.put(p.AssigneeId,p);
    }
    system.debug('---------Permission Set Values-----------'+s.KeySet());
    
    if (s!= null) {
      //UserList = [Select Name, Id, IsActive, UserType From User where IsActive=true and UserType = :USERTYPE_STD and Id IN :InitialRightList limit 500];
     UserList = [Select Name, Id, IsActive, UserType From User where IsActive=true and UserType = :USERTYPE_STD and Id IN :s.KeySet() limit 500];
     system.debug('---------Permission Set Values-----------'+UserList);
      for (User u : UserList) {
      
        LeftOptionMap.put(u.Id, u);
       
      }
   
    } 
   
    TempValueList = LeftOptionMap.values();
    TempValueList.sort();  // sort by name
    for (User u : TempValueList) {
      TempOptionList.add(new SelectOption(u.Id, u.Name));
    }
    return TempOptionList;
  }