How do i Call a script include from Module Arguments

vtred
Tera Contributor

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

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Vt,



Please refer sample ex 10.1 and adjust your code accordingly.


Using Filters and Breadcrumbs - ServiceNow Wiki


Paramahanns
Tera Expert

Hi Vt,



Please try this way it works in my instance.



find_real_file.png



Calling the function in the script include should be as below.



find_real_file.png



Hope calling the script was your question. Please mark as correct or helpful if this helped you.



Regards


Param


shloke04
Kilo Patron

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:



find_real_file.png



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


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

vtred
Tera Contributor

Thank you All,



I could get into the script include, but i couldn't set the filters for the table by returning the value on script include.



This is the output am getting


find_real_file.png