Validating a choice field type value in a script include

David Miller1
Tera Guru

I'm trying to validate that when a scipt include is updating incident for example, that values of the choice type fields are valid.

 

I was hoping I would not have to query sys_choice but I'm facing troubles.

 

I've tried two approaches so far:

 

GlideChoiceList -> .getChoiceList

Using this with a table name and field name  is almost what I want. But it does not take in to account dependent values.

 

Element -> getChoices

Again this is very close to what i need, you can even pass a dependent value in. However, it gives you the base table values which is not so useful if new values have been added to an extended table.

 

Is my only option querying sys_choice. I suppose I've got a query to be quite specfic by this point but I would still rather not make a query.

 

Thanks.

1 ACCEPTED SOLUTION

David Miller1
Tera Guru

 

var cgl = new GlideChoiceListGenerator(table, field, 'dependentValue');
var choiceListObj = cgl.get();

 

Seems to give me what i want.

View solution in original post

1 REPLY 1

David Miller1
Tera Guru

 

var cgl = new GlideChoiceListGenerator(table, field, 'dependentValue');
var choiceListObj = cgl.get();

 

Seems to give me what i want.