Possible to remove a choice from a reference variable if it is already selected in a Multirow Variable set?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 03:31 PM
I've got a Multirow variable set that is set up to return users only associated to a common cost center - that part works great.
What I am wondering is if there is something out there that can remove a choice from that reference list once that user has been selected. Currently I can select the user, fill out the mandatory fields and Add them to the MRVS. Then when I click "Add" again, that same user is still there and available for selection. Once they are selected I'd like to remove them.
Has anyone ever done this or know how?
Here is an example of what I am talking about - I have already selected myself and added my record to the MRVS, but when I click Add again, I am still there available for selection.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 05:19 PM
You should be able to utilize an advanced reference qualifier to update the choices available within the list field based on prior input from the user.
Take a look at a similar example here: https://community.servicenow.com/community?id=community_question&sys_id=8fd60853db946410fb115583ca961971

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 05:20 PM
So you could potentially do this, with quite a bit of difficulty and probably some undesired side-effects.
The only method I could think of would require you to write the selected users back to your catalog item with each row submit, and on each row load pull in that list to a hidden field on the MRVS (hidden on the modal but not on the row list) and then write a complicate reference qualifier to take the value of the field, and modify your query with a bunch of "^sys_id!=" statements to exclude the already selected users.
You would have to use some unorthodox methods to be able to write values from within the MRVS to the form and then load them back with each row, and you would have to do this as you can only reference fields on the MRVS form itself as part of a reference qualifier.
As an alternative you might consider using the "unique" checkbox on the variable itself. That would prevent the user from adding multiple rows with that same value.
I hope this helps!
If this was helpful, or correct, please be kind and mark the answer appropriately.
Michael Jones - Proud member of the GlideFast Consulting Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 07:05 AM
Thanks for the reply - I am already using the unorthodox method to push cost center in to the MRVS which is what the advanced ref qualifier on the user name field is filtered off of.
I will try the unique checkbox, although I thought when I looked yesterday there wasn't an option for that on the variable.
(Just checked and it wasn't on the form, I will add it and give that a shot)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 07:06 AM
That works for limiting it, which is good enough! Thanks!