Set a list collector with default value in the Right column

EricG
Kilo Sage

I've read the many posts regarding list collectors and have attempted to use the suggestions proposed on each, modifying for what i need to achieve.  And sadly, i'm all little confused/perplexed.

The Requirement:

On my Corporate App access request, there is a variable where users select the "Position" they need to have in the app.   E.G.  Data Entry, Procurement, Analyst, etc...

Based on this, there may be a single role for that function or many that they may request to be assigned to them.
So, I'm able to associate Position to Roles with no issue and have the List Collector only show the roles for each position should there be multiple.

What i need to happen is already have 2 base roles selected (right side)

user role and company role (base on which company user is from)

These are two roles that must be included for each user.

I've thought that i could have all roles on the right side, with note on form to remove those not wanted.
But they might remove user and company by mistake.

So I'm at a loss as to how to get the two into my list collector

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Hi Eric,

What you need to do is actually move them from the left to right, so first you have to ensure that these 2 roles appear on the left within the x number of results returned without having to type anything in the Available search box, or alter the query.  Once you've confirmed that they are shown on the left, a script like this will move them to the right.  Make sure the Isolate script box is unchecked, and adjust the number at the end of the timeout function call (currently 3 seconds) if your list takes longer to load, or if there's too long of a wait before you see the 2 choices move.

var varName = 'roles';//name of your list collector variable
window.setTimeout(function(){
  var leftBucket = gel(varName + '_select_0');
  var rightBucket = gel(varName + '_select_1');
  var selectedOptions = leftBucket.options;
  var selectedIDs = new Array();
  var index = 0;
  for(var i = 0; i < selectedOptions.length; i++){
    if(selectedOptions[i].value == 'sys_id of user role' || selectedOptions[i].value == 'sys_id of company role'){
      selectedIDs[index] = i;
      index++;
    }
  }
  rightBucket.options.length = '0';
  moveSelectedOptions(selectedIDs, leftBucket, rightBucket);
  sortSelect(rightBucket);
}, 3000);

Brad Bowman
Kilo Patron
Kilo Patron

Were you able to test this solution to see if it meets your requirements?

Just saw this.  sorry.  I've been away