- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2019 10:34 PM
I have a requirement to make a module that has a specific fixed filter. I know how to use javascript to get information in there, but the issue I'm running into is that it seems as if only one javascript entry per filter seems to work.
Basically I need a field to look like <Logged in user last name>, <Logged in user first name>
I expected it to look like:
&sysparm_fixed_query=primary_rep=javascript:gs.getUser().getLastName() + ", " + javascript:gs.getUser().getFirstName();
However the above doesn't work. I tried seeing if I could do variables, and that was just craziness. Anyone have any thoughts?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2019 12:03 AM
can you paste the screenshot of your script include ?
if script include as written in scoped application then you have to mention the scope name.
example:
&sysparm_fixed_query=last_name=javascript:new <your application name>.<script include name>().get()
for scoped application script include try with below code:
var testina = Class.create();
testina.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
get: function(){
var id = gs.getUserID();
var gr = new GlideRecord('sys_user');
gr.get(id);
var fn =gr.first_name;
var ln = gr.last_name;
var op=fn+','+ln;
gs.info('result is'+op);
return op;
},
type: 'testina'
});
Arguments : &sysparm_fixed_query=last_name=javascript:new x_43765_test.testina().get()
Note: x_43765_test is my application which you will find from the "API Name" field from script include.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2019 11:29 PM
did you try with script include ?
create one client callable script include and then you can call it in sysparm_fixed_query .
Sample: code:
var check = Class.create();
check.prototype = Object.extendsObject(AbstractAjaxProcessor, {
get: function(){
var fn =gs.getUser().getFirstName();
var ln = gs.getUser().getLastName();
var op=fn+','+ln;
gs.log('result is'+op);
return op;
},
type: 'check'
});
In arguments : &sysparm_fixed_query=short_description=javascript:new check().get()
Note: I tested with short_description field. you can add your field here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2019 11:49 PM
I did try this without success. Took your code and it still isn't working. This worked for you in your test? What version of ServiceNow did you test this in?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2019 11:51 PM
i am on madrid , i have used it on global scope , are you using it in scoped application ?
can you put the log in your script include and check the result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2019 11:58 PM
getName is the script include name, it is client callable, I did set it to all application scopes, although its application is a different scope from Global, but so is the module.
org.mozilla.javascript.EcmaError: "getName" is not defined.
Caused by error in <refname> at line 1
==> 1: new getName().get()