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

dynamic filter option on reference field

Rj27
Mega Guru

Hi All,

Can we define dynamic filter option on 'requested for' reference field as shown?
Can we use 'current' this way directly? Because the following script is not working at all.
Note: I am using this under default value related list with a reason to set default values when i click on lookup option. From reference qualifier i am returning something else and can't define the default values there.

find_real_file.png

 

find_real_file.png

38 REPLIES 38

Hi,

I think as mentioned earlier you need to return the records from the dynamic filter and not the query

So you should query sys_user table with the above query and then return the records

var getRequestedFor = Class.create();
getRequestedFor.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getReqFor: function() {

var query = '';
query = 'active=true^sys_domain=' + gs.getUser().getDomainID(); // if you want current user domain

var userRec = new GlideRecord('sys_user');

userRec.addEncodedQuery(query);

userRec.query();

while(userRec.next()){

arr.push(userRec.sys_id.toString());

}

return arr.toString();

},

type: 'getRequestedFor'
});

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

tried this way also..but not getting the value as expected.

It seems the script include is not at all called from dynamic filter option else i would have atleast got the log which is first line of code inside the function and outside the gliderecord.

getReqFor: function() {

gs.log('Test');
var query = '';
query = 'active=true^name=Abel Tuter';


var userRec = new GlideRecord('sys_user');
userRec.addEncodedQuery(query);
userRec.query();
while (userRec.next()) {
arr.push(userRec.sys_id.toString());
}
return arr.toString();

},

Hi,

Can you remove gs.log() and use gs.info() instead

the script include if client callable should be able to call from dynamic filter

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

gs.info also not working 

Hi,

Can you create classless script include and check one

Can you share screenshot on how are you applying it on the related list?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader