- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Some times we require to fetch/print the choice values/labels of a field to perform some validations or print them in an email notifications etc.
So here is a sample script which can be utilized and re-used as per the business requirement.
Note: This works in both global and scoped application
I just took an example of incident and change_request table and field as close_code
Script: For incident table
var choices = GlideChoiceList.getChoiceList("incident", "close_code");
for (var i = 0; i < choices.getSize(); i++){
var choiceValue = choices.getChoice(i).getValue();
var choiceLabel = choices.getChoice(i).getLabel();
gs.info("Choice Label -> " + choiceLabel + " Choice Value ->" + choiceValue);
}
Choice Table:
Output:
Another Example for change_request table and field as close_code
Script: For change_request table
var choices = GlideChoiceList.getChoiceList("change_request", "close_code");
for (var i = 0; i < choices.getSize(); i++){
var choiceValue = choices.getChoice(i).getValue();
var choiceLabel = choices.getChoice(i).getLabel();
gs.info("Choice Label -> " + choiceLabel + " Choice Value ->" + choiceValue);
}
Choice Table:
Output:
Thanks for reading the blog and do provide your inputs/suggestions if any.
Hope you find this article helpful. Don’t forget to Mark it Helpful, Bookmark.
Thanks,
Ankur Bawiskar
- 6,615 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.