The CreatorCon Call for Content is officially open! Get started here.

Reference Qualifier onChange

Michael Gedzelm
Tera Contributor

Hi.  I am attempting to create an advanced reference qualifier that runs when another field changes (before saving) but have been unsuccessful, as it only seems to run onload, not onchange. For example (only an example, what I'm trying to do is more complex), let's say I have two reference fields: states of the country (i.e. Alaska, Arkansas, etc.) and counties of the state. When the user changes the state, the reference qualifier should run and show only the counties in the state I have chosen. But the reference qualifier only seems to run after a save (onload). As mentioned earlier, what I'm trying to do is far more complex than this example and I need to run javascript on the server each time a field is changed. The main issue is how do I get a reference qualifier to run onchange before a save. Thanks.

1 ACCEPTED SOLUTION

Yes it works for me

Ref qualifier: javascript:new FillServers().pickServers(current)

SI: Client callable checked

var FillServers = Class.create();
FillServers.prototype = Object.extendsObject(AbstractAjaxProcessor, {
pickServers:function(){
var servers = [];
var location = current.u_location.getValue();
var cls = current.u_server_class.getValue();
if(!location && !cls)
return;
gs.log('Returned null', 'prateek');
var ci = new GlideRecord('cmdb_ci');
ci.addEncodedQuery("sys_class_name="+cls+"^locationLIKE"+location);
ci.query();
while(ci.next()){
servers.push(ci.name.toString());
}
return 'nameIN'+ servers;
},
type: 'FillServers'
});

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

15 REPLIES 15

Glad that your issue was resolved. can you mark the appropriate response as correct and close this thread.

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks