- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 11:55 AM
Hello,
We have a requirement where a filed needs to change based on another field.
If "Cost center" change then "EOC" should display the "list of codes" based on selected "Cost center"
I'm a novice at scripting. Any help would be greatly appreciated.
Thank you 🙂
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2020 09:10 AM
Thanks everyone. We ended up getting help from the vendor and they were able to do the needful. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:16 PM
What are the field or variable types of Cost center and EOC? The complexity of your onChange script will depend on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:21 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:47 PM
Hi Gurbir,
Are both the fields Cost Center & EOC referencing same table or different.
Also, did you check comment from Mike something similar will have to be done as reference qulaifier is best fit for your business case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 01:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2020 12:48 AM
You can try something as below (sample script).
Create a Script include as below.
var getEOCCode = Class.create();
getEOCCode.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getEOC: function(costcenteris) {
var finalis=[];
var yis = new GlideRecord('yourtablename'); //replace correct table nae
yis.addQuery('sys_id', costcenteris);
yis.query();
while (yis.next()) {
finalis.push(yis.eoc.toString());//replace eoc with correct field name
}
return 'yis.eoc.sys_idIN'+finalis; //replace eoc with correct field name
},
type: 'getEOCCode'
});
Pass the reference qualifier on the EOC field as
javascript: new getEOCCode().getEOC(current.cost_center);
//replace cost_center with correct field from the form.