How do i Call a script include from Module Arguments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 02:51 PM
Hi,
I have a requirement where, when a user clicks on a module it should call the below script include and it should set the filters on the teble related to the module according to the script.
THIS SCRIPT IS MARKED CLIENT CALLABLE
var ModuleArg = Class.create();
ModuleArg.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
ModuleTesting: function() {
var abc = new GlideRecord('u_test');
abc.query();
while(abc.next())
{
var xyz = "u_field1=option1"; // field1 and field2 are the fields on the table linked to the module on which the user clicks
var pqr = "u_field2=option2";
var x = abc.u_test_field1; // u_test_field1 and u_test_field2 are the fields referring to groups, on the table - u_test, in which the user should be a member of
var y = abc.u_test_field2;
var user = gs.getUser();
if(user.isMemberOf(x))
{
gs.log("success1");
return xyz;
}
elseif(user.isMemberOf(y))
{
gs.log("success2");
return pqr;
}
}
},
type: 'ModuleArg'
});
THE ABOVE SCRIPT IS WORKING FINE (tested it in background scripts). THE ONLY ISSUE IS WITH CALLING THE ABOVE SCRIPT FROM THE ARGUMENTS FIELD IN MODULE.
Argument section for the Module:
Arguments tried:
javascript:new ModuleArg.ModuleTesting()
javascript:ModuleArg.ModuleTesting()
javascript:new ModuleArg()
javascript: ModuleTesting()
What would be the changes that i have to do in order to call the script include?.
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 02:54 PM
Hello Vt,
Please refer sample ex 10.1 and adjust your code accordingly.
Using Filters and Breadcrumbs - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 03:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 06:25 AM
Hi,
What is your Script Include Name? Can you try the below, it should work:
javascript: Your Script_Include Name()
Or You can also try Dynamic Filter Options and use it in the Filter of the Module as "Field is(dynamic) "Filter Name Created". For example as one shown below:
Review the below Link Point Number 10 on the same:
Using Filters and Breadcrumbs - ServiceNow Wiki
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 01:04 PM