dynamic filter option on reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2020 10:06 PM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 04:00 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 04:36 AM
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();
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 05:17 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 05:32 AM
gs.info also not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 07:37 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader