How to handle varying category values/dependent values?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 02:23 AM
Hi everyone.
Ok, so I have this problem I'd love some input on how to solve:
- Depending on which assignment group is chosen, certain categories become available.
- Depending on which category, certain subcategories become available.
So far so good, that's easy enough. I set the dependent value to the sys_id of the assignment group, which makes that category appear when that assignment group is chosen.
These categories may be:
- Cat A
- Cat B
- Cat C
And the subcategories may be:
- Subcat A
- Subcat B
- Subcat C
However, let's say some of the assignment groups need to share some of the categories.
Let's say that Cat A needs to be shared between two assignment groups.
I've tried creating duplicate entries into the category choices, each with the same name, but with different dependent values. So, depending on which assigmentgroup the categories would look the same, and submit using the same choice name.
This creates an error when I want to submit the incident. It basically says "java.sql.batchupdateexception duplicate entry 'sys_id' for key 'PRIMARY'".
I could simply change the names, and have the labels be identical. But in a reporting situation, that wouldn't work very well.
So, how do I solve this problem in a smart way? Any input on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 02:33 AM
Hi Jacob,
The field dependencies are a bit limited in that you can only make a choice option dependent on 1 value.
I think your best option is to run an onChange client script to populate the category field with the choices you need. You can call a glide ajax and then run some queries in a script include to get an array of the appropriate choice options for the assignment group and then set them in the client script using g_form.addOption.
Regards
Dave

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 03:00 AM
Hmm.
I'm thinking, if I created these values once, set the depending value to e.g. "shared", I should be able to query on "any values with a dependant value of "shared", use g_form.addOption.
Think that could work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 03:09 AM
Hi Jacob,
I would agree with David, but I would also see if I can add a field on the sys_choice table, that is a GlideList table, and refers to group table, so you can have multiple group for the same choice. And then use the script include to collect the choices you need, checking for that custom field, and add the options as David suggested with client script.
And your subcategory field can be controlled by the dependent field, as you are aware as per your comments in the suggest.
The only this you might need to check if we should be adding a new field on sys_choice table for this customisation. I have never tried it, but it is an option.
Hope this helps?
Regards,
Vikrant Sharma
Thanks & Regards,
Vikrant Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 03:29 AM
Yeah for sure you'd need a list on the category form so that you can list the assignment groups the choice option is relevant for and then you can use that data to build your glide query in the script include and populate the array.