Apr 16, 2017

Dynamically Move List Collector Options in ServiceNow

For basic information go to List Collector. My requirement was to populate List Collector dynamically on change of requested for.

Solution: List Collector or slashbucket stores values on basis of index values of left side options and index values in a list should be sorted.

var varName = 'u_app_name';
  var leftBucket = gel(varName + '_select_0');
  var rightBucket = gel(varName + '_select_1');
  var allOptions = leftBucket.options;
  
//on requested for change first clear rightBucket
  while(rightBucket.firstChild) {
                if(rightBucket.firstChild != null && rightBucket.firstChild != '') {
                    rightBucket.removeChild(rightBucket.firstChild);
                }
            } 
   
   //Get all the options from custom table
  var grApp=new GlideRecord('u_swo_application_list');
  grApp.query();
  
  while(grApp.next())
   {
   var exist=false;
   for(var i=0;i    {
    if(allOptions[i].value==grApp.sys_id)
     {
     exist=true;
    }
   }
   if(!exist){
   //add option to right side bucket
    var option = document.createElement("option");
    option.value = grApp.sys_id;
    option.text = grApp.u_application_name;
    leftBucket.add(option);
   }
  }
  sortSelect(leftBucket);
  allOptions = leftBucket.options;
  
  var selectedIDs =[];// new Array();
  
//custom table where storing right side slashbucket options   var gr=new GlideRecord('u_swo_leaver_and_joiner');
// caller is requested for value i.e sys_id
  gr.addQuery('u_requested_for.sys_id',caller);
  gr.addQuery('u_access',true);
  gr.query();
  var index=0;
  while(gr.next())
   {
   
   //selectedIDs[index]=index;//gr.u_application;
   for(var j=0;j    {
    
    if(allOptions[j].value==gr.u_application)
     {
     //insert index value only
     selectedIDs[index]=j;
     index++;
     break;
    }
   }
  }
//sort array
   selectedIDs.sort();
  moveSelectedOptions(selectedIDs, leftBucket, rightBucket,'-None-');
  sortSelect(rightBucket); 

17 comments:

Unknown said...

the blog is about Dynamically Move List Collector Options in ServiceNow it is useful for students and servicenow Developers for more updates on servicenow follow the link

ServiceNow Online course

For more info on other technologies go with below links

tableau online training hyderabad

Python Online Training

mulesoft Online Training


chandar jun said...

Very nice and well done thanks for the useful information
ServiceNow Training in Hyderabad, servicenow training ameerpet, service now interview questions on scripting, servicenow tutorial, servicenow online training, servicenow online course, servicenow courses, servicenow training videos, service now administration training in hyderabad

Unknown said...

well done the blog is great and it is about"Dynamically Move List Collector Options in ServiceNow" it is useful for students and servicenow Developers for more updates on servicenow ServiceNow Online course

soumya said...

Thanks for sharing valuable information with us, keep share content on ServiceNow Online Training

Unknown said...

Excellent piece of information, I had come to know about your website,i have read some posts of yours by now, and let me tell you, your site gives the best and the most interesting information. ServiceNow provides a platform and suite of applications as a service. They worry about the hardware, Internet connectivity, and operating system security and provide you with the URL. All you need to get going is a web browser.
ServiceNow Tutorual

akhilapriya404 said...

The information which you have provided is very good. It is very useful who is looking for selenium Online course Bangalore

Unknown said...

I found your blog very interesting and very informative.I like your way of writing and explaining the topics. ServiceNow progress, supports and implements a suite of on-demand IT service management features offered via the Internet as software as a service (SaaS). These features are licensed on a simple and economical subscription basis. The latest release of ServiceNow is Fuji Readmore..

Unknown said...

I found your blog very interesting and very informative.I like your way of writing and explaining the topics. ServiceNow progress, supports and implements a suite of on-demand IT service management features offered via the Internet as software as a service (SaaS). These features are licensed on a simple and economical subscription basis. The latest release of ServiceNow is Fuji Readmore..

IT Canvass said...

very informative blog... interesting to read
service now administration training

hkrsupports said...

developer support
Great post . thanks for sharing a clear step by step process on getting in the nice.
thank you.

HKR Trainings said...

Linux training online
Very Nice Article…..thank you for sharing

Training for IT and Software Courses said...

Thanks For sharing a nice post about servicenow Training Course.It is very helpful and servicenow useful for us.servicenow training in bangalore

Training for IT and Software Courses said...

Excellent information with unique content and it is very useful to know about the servicenow.servicenow training in bangalore

Training for IT and Software Courses said...

Excellent information with unique content and it is very useful to know about the servicenow.servicenow training in bangalore

Veera Blogspot said...

Very nice article,Thank you for sharing this Unique Content.
Keep Updating...

ServiceNow Online Training

Nikhil Sharma said...

I read your post. It is very informative and helpful to me. I admire the message valuable information you provided in your article.
devops online training

Nikhil Sharma said...

I read your post. It is very informative ad helpful to me. I admire the message valuable information you provided in your article.
power bi training