Comments on: Limiting Number of Selections in a List Collector https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 21:20:06 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mila Morales https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7145 Thu, 14 Sep 2017 15:00:52 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7145 In reply to amrita.

You can use this onchange script to limit the options in the list collector in Service Catalog.
varName will be the name of list collector and maxSelections will be the maximum number options.

function onChange(control, oldValue, newValue, isLoading) {
var varName = ‘users’;
var maxSelections = 20;

$$(‘#’ + varName + ‘_select_0 option’)
.each(function(elem,index){
if(index >= maxSelections)
elem.remove();
});
}

]]>
By: amrita https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7142 Wed, 07 Jun 2017 11:48:35 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7142 Hi Mark , How can i limit the number of entries on a list collector on a form?

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7141 Tue, 28 Mar 2017 19:34:57 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7141 In reply to Mohammed.

Sure, check out the post above for the newly-added Service Portal version of this script. You’ll need to have 2 separate client scripts…each one running for a different UI type (Desktop and Mobile).

]]>
By: Mohammed https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7140 Tue, 28 Mar 2017 14:37:46 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7140 Hi Mark,

Thank you for the great post. I used this script it on one of my variable and it worked fine in the servicenow native UI. But, we are on Helsinki and the business users are using service portal to log their request. List collector behave differently on service portal. By different I mean, their is no right and left slush bucket so your script doesn’t work on service portal. Can you please provide a modified version of your script that could work even on portal list collector variable?

Thank you!

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7139 Wed, 28 Sep 2016 13:47:30 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7139 In reply to Leslie Know.

Unfortunately no. This is the big challenge with service portal at the moment. Lots of flash and marketing hype, but really limited API and client scripting flexibility.

]]>
By: Leslie Know https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7138 Wed, 28 Sep 2016 13:39:51 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7138 Hello, I have this working in a record producer on the CMS portal. However, the new Helsinki Service Portal does not support DOM manipulation. Is there a way to limit the number of selected options in a list collector in the Service Portal?

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7137 Wed, 28 Oct 2015 17:55:37 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7137 In reply to Chenelle Stewart.

You can disregard that warning. The script should work fine regardless.

]]>
By: Chenelle Stewart https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7136 Wed, 28 Oct 2015 17:47:46 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7136 So i am getting an error this error using this script
WARNING at line 11: Use the array literal notation [].
When I change the (); to []; it still doesn’t work. Please advise. Using Fiju

]]>
By: Erik Myrold https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7135 Mon, 27 Aug 2012 17:46:27 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7135 In reply to Mark Stanger.

Cool, will do that… thanks so much for the reply…!!! Will reply back once we figure out what we did wrong… :-)

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/limiting-selections-list-collector/#comment-7134 Mon, 27 Aug 2012 17:43:17 +0000 https://servicenowguru.wpengine.com/?p=1743#comment-7134 In reply to Erik Myrold.

I just tested this on a ServiceNow demo instance and it worked perfectly there. I just pasted directly into a new ‘onChange’ catalog client script, changed the name of the variable to match in the script, and ran it. You should try to see if you can get it working on a test in demo. My guess is that there’s something else in your environment causing issues.

]]>