How to copy 'Product' choice list from Incident to Problem table

jas101
Tera Expert

Hey everyone

We're overhauling our Problem module. It looks like the Category field currently on the Problem form mirrors that on the Incident form - note it is not on task table so the field and choice value must have been manually inputted on the problem table.

Now it is being asked if we can use the same Product choice list on the Problem form that is currently on Incident - the Products available to select on Incident form being dependent on the Category chosen.

So my question: How can I most easily transfer the entire Product choice list across to Problem without manually inputting anything - and is there anyway to ensure the 'dependent' values are kept too? Presumably they would be as long as current Problem Category values match Incident Category values.

In the longer term I guess we would want to consider moving this to task table so then it can be used easily from any table right?

Many thanks in advance guys.

Daniel

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

You can actually share the same list of choices for both tables.   Right-click the "Category" label on your Problem form and select "Configure Dictionary".   Then select "Incident" for the "Choice table" and "Category" for the "Choice field" (you may have to switch to the "Advanced" view of the form depending on the version of your instance):


____Jim_C_____.png



Any changes to the list will be seen in both forms.


View solution in original post

8 REPLIES 8

timmyweytjens
Tera Expert

You can try running a background script like this:



var grChoice = new GlideRecord('sys_choice');


grChoice.addQuery('name', 'incident');


grChoice.addQuery('element', 'u_product'); // this is the name of the field for your product list


grChoice.addActiveQuery();


grChoice.query();


while(grChoice.next())


{


    var grNewChoice = new GlideRecord('sys_choice');


    grNewChoice.initialize();


    grNewChoice.name = 'problem';


    grNewChoice.element = 'u_product'; // the name of the field in problem


    grNewChoice.language = grChoice.language;


    grNewChoice.label = grChoice.label;


    grNewChoice.value = grChoice.value;


    grNewChioce.dependent_value = grChoice.dependent_value;


    grNewChoice.hint = grChoice.hint;


    grNewChoice.sequence = grChoice.sequence;


    grNewChoice.insert();


}


Jim Coyne
Kilo Patron

You can actually share the same list of choices for both tables.   Right-click the "Category" label on your Problem form and select "Configure Dictionary".   Then select "Incident" for the "Choice table" and "Category" for the "Choice field" (you may have to switch to the "Advanced" view of the form depending on the version of your instance):


____Jim_C_____.png



Any changes to the list will be seen in both forms.


This is great, many thanks Jim! So now I have both Category and Product choice lists showing on the Problem form (both originating on Incident) is it possible for the 'Dependent' values to be 'inherited' at all or will I need to configure these manually?



Cheers.Daniel


You will also have to set the Product field on the Problem form to be dependent on the Problem's Category field and then you will have matching dependent choice lists on both tables.