Module Arguments

Community Alums
Not applicable

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?

1 ACCEPTED SOLUTION

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. 

View solution in original post

7 REPLIES 7

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. 

Harsh Vardhan
Giga Patron

any update on this thread?

 

if your query has resolved , kindly mark the answer correct and close this thread. 

abhisheksolanki
Giga Contributor

I had a similar issue and it needed 2 changes - 

1) Replace sysparm_fixed_query with sysparm_query
2) Replace the plus sign + with its encoded version %2B

While I have no clue why the former is necessary, for the latter one the Docs do talk about the developer having to encode URIs starting with &. Oddly, nothing else needs to be encoded; just that plus sign.


https://docs.servicenow.com/bundle/quebec-platform-user-interface/page/administer/navigation-and-ui/concept/encoding-module-uris.html

Also, check your node logs (System Logs > Node Log File Browser) if your Module link is breaking or not working as expected. If it is a URI encoding issues, the logs will indicate so. For example, when I was using the +, it was disappearing when the request was being processed by the server.