Edit group members Catlog Item

abhiyadav2001
Giga Expert

Hi,

 

I have a requirement where Manager should be allowed to edit the group members ( add / remove ) of the groups that he / she is managing.

 

I have created below variables in Catalog item.

1. Reference : User Assignment group table (sys_user_group) : This displays the groups which are managed by 'logged   In' user. I put a reference qualifier here to display particular groups.

 

2. List Collector :

I am thinking to use 'Group Edit' form / page on the Catalog item ( I think this will make my work easier) , pls find the attached screenshot

This form displays the 'existing users' of the groups on the right side and Other users on the left.

 

Is it possible to have that complete page in the Catalog item ? Where to find that page ?

 

Is there any other approach you think will be easier ?

 

Thanks,

Abhijeet

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

here is the code for changing the filter of slush bucket and preloading the selected options on the right side... make changes according to your requirement.. Hope this helps



onchange function()


{


      if(!isLoading)


              {


              //ci is the variable name of slush bucket. replace ci below lines with your variable name


              var query = "^u_active=" + newValue+"^name!=";


              cig_filter.reset();


              cig_filter.setQuery(query);


              ciacRequest(null);


             


              if(newValue=='true')


                      {


                      setTimeout("defaultSelectedOptions();", 5000);


              }


                     


      }


}




function defaultSelectedOptions()


{


      try


      {


              var loadInitialValues = '6fd6bc05871d10005ea5476dff434d69,bbd7bc45871d10005ea5476dff434dca'; //values to load


             


              var varName = 'ci'; //slush bucket variable name


              var leftBucket = gel(varName + '_select_0');


              var rightBucket = gel(varName + '_select_1');


              rightBucket.options.length = '0';


              var leftOptions = leftBucket.options;


              var selectedOptions = loadInitialValues.split(',');


              var selectedIDs = new Array();


              var index = 0;


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


                     


                      for(var j = 0; j < selectedOptions.length; j++){


                             


                              if(leftOptions[i].value == selectedOptions[j]){


                                      selectedIDs[index]= i;


                                      index++;


                              }


                      }


              }


             


              moveSelectedOptions(selectedIDs,leftBucket, rightBucket, '');


             


      }


      catch(err)


      {


              alert(err);


      }


}


View solution in original post

22 REPLIES 22

i do not think that is ui page... the catalog item option should be simple enough to set up and running.... the approach of Mandar Kamtekar seems to be the way to go...


Kalaiarasan Pus
Giga Sage

here is the code for changing the filter of slush bucket and preloading the selected options on the right side... make changes according to your requirement.. Hope this helps



onchange function()


{


      if(!isLoading)


              {


              //ci is the variable name of slush bucket. replace ci below lines with your variable name


              var query = "^u_active=" + newValue+"^name!=";


              cig_filter.reset();


              cig_filter.setQuery(query);


              ciacRequest(null);


             


              if(newValue=='true')


                      {


                      setTimeout("defaultSelectedOptions();", 5000);


              }


                     


      }


}




function defaultSelectedOptions()


{


      try


      {


              var loadInitialValues = '6fd6bc05871d10005ea5476dff434d69,bbd7bc45871d10005ea5476dff434dca'; //values to load


             


              var varName = 'ci'; //slush bucket variable name


              var leftBucket = gel(varName + '_select_0');


              var rightBucket = gel(varName + '_select_1');


              rightBucket.options.length = '0';


              var leftOptions = leftBucket.options;


              var selectedOptions = loadInitialValues.split(',');


              var selectedIDs = new Array();


              var index = 0;


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


                     


                      for(var j = 0; j < selectedOptions.length; j++){


                             


                              if(leftOptions[i].value == selectedOptions[j]){


                                      selectedIDs[index]= i;


                                      index++;


                              }


                      }


              }


             


              moveSelectedOptions(selectedIDs,leftBucket, rightBucket, '');


             


      }


      catch(err)


      {


              alert(err);


      }


}


Hi Kalai,



It worked for me with modifications. I used below code to search users belong to the selected group



function searchMembers(group){


var answer = '';


var memberGR = new GlideRecord('sys_user_grmember');


memberGR.addQuery('group', group);


memberGR.query();


while(memberGR.next()){


     


      answer += ',' +memberGR.user;


}


return answer;



Surprisingly, Gel () isn't working. So,I used variable names directly.



Thanks for that code. It really helped a lot !



Is there any way to override / code Slushbucket Add/ Remove button code?



-regards,


Abhijeet


not sure abt that one... but why do you wanna change the code of add/remove button ?


i am guessing that your are thinking of setting some variable whenever the values are added or removed ...


if that is the case, you can just make use of a onchange script ... why unnecessary messing up of DOM objects



and one more thing mark the question as answered


Hi Kalai,



Yes, I want to set variables on click of 'add / remove'. But the event triggers once I click those buttons. ( or double click on the list element ). I guess I need to play with the code of 'Add/remove' button to set variable values.



-Abhijeet