SHow/ HIde List collector variable options.

ar1
Kilo Sage

Hi All,

Can anyone please help us on the below requirement.

 

We developed one catalog with few variables.

In that one variable callled Company (Select Box type) with drop down options.

ANd another variable called Region (List collector type ---> Refer to Regions table ---> Region field {List field type}).

 

And now we want to display the Region choices in slush bucket based on the Company variable selection.

 

Can anyone please help us with sample script.

Note: Gone through few link in community but no luck.

Advance thanks for the support.

1 ACCEPTED SOLUTION

ar1
Kilo Sage

Hiii,

Below script working fine for us.

Many thanks to @Ankur Bawiskar  and  @Allen Andreas .

 

Client script:

function onChange(control, oldValue, newValue, isLoading) {
var headers = g_form.getControl('u_region').parentElement.querySelectorAll('.col-xs-4');
 var collectorName = 'u_region';
var filterString = '';    
    if(newValue == 'Australia'){
        filterString = 'question.nameSTARTSWITHu_region^textNOT LIKEAustralia';
    }
    else if(newValue == 'Austria')
    {
        filterString = 'question.nameSTARTSWITHu_region^textNOT LIKEAustria';    
    }

    setCollectorFilter();
    
function setCollectorFilter()
{
//If it hasn't rendered yet, wait 100ms and try again.
if(typeof(window[collectorName + 'g_filter']) == 'undefined')
{
setTimeout(setCollectorFilter, 50);
return;
}
//Reset the filter query
window[collectorName + 'g_filter'].reset();  
window[collectorName + 'g_filter'].setQuery(filterString);  
window[collectorName + 'acRequest'](null);  
//Redisplay the list collector variable
//g_form.setDisplay(collectorName,true);
    
}

   
}

 

View solution in original post

10 REPLIES 10

Allen Andreas
Administrator
Administrator

Hello,

You'd need to use a reference qualifier to filter the region choices based on the company field. The company field would need to be related to regions for this to work.

Then, you can set a reference qualifier on the regions field with something like:

javascript:"company="+current.variables.company_field_name;

The above is an example and you'd need to replace company with the correct field name on the region table where the company data is referenced and then company_field_name with the appropriate company variable name.

ALSO...the select-box choices should have a value of the company sys_id as well, if the company field on the regions table is a reference.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

Many thanks for the response.

We tried your suggestion, but we found one issue on slush bucket level.

In slush bucket the option displaying like below, will it possible to display the option one by one   (Like Down)

and user can select all the options or needed options.

 

 

 

@Ankur Bawiskar 

Could you pls help us.

 

Many thanks for the support.

Hi,

The column which is marked as Display=True on your Regions table must be having the values as comma separated and hence it's showing like that.

Each row of slush bucket is a row on the Regions table

So whatever you are asking is not possible unless those are separate rows.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader