Pass variable to script include from reference qualifier

robhaas
Tera Contributor

I have an advanced reference qualifier calling a script include and passing it current.

javascript:new global.COMP_UserHelpers().showInactive(current);

I am needing to pass a different variable to the script include. Is it possible to define and pass this variable in the reference qualifier? I tried the following two permutations in attempt to pass the variable tmpShowInactive with no luck. Any thoughts?

javascript:new global.COMP_UserHelpers().showInactive(var tmpShowInactive = {u_show_termed_users : true});

javascript:var tmpShowInactive = {u_show_termed_users : true} new global.COMP_UserHelpers().showInactive(tmpShowInactive);

TIA for assistance.

11 REPLIES 11

Deepa Srivastav
Kilo Sage

Why do you wanna do that...is u_show_termed_users a field on the current form? if yes then you can simply pass..current.u_show_termed_users to send the value of current.u_show_termed_users. Please clarify.
javascript:new global.COMP_UserHelpers().showInactive(current.u_show_termed_users)



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


Abhinay Erra
Giga Sage

If this is in a reference qualifier, you do not need to pass any parameters. Script include will automatically have access to current object.


robhaas
Tera Contributor

So current object is now a new form. When the original form was created, it does have a field named u_show_termed_users. However, I am looking to call this from a different form that does not contain the u_show_termed_users field. I was thinking that I could pass a temp variable in place of 'current'   and set the u_show_termed_users field to 'true'.   Maybe there is a better way to do this? I was just trying to avoid creating another script include or adding the u_show_termed_users field on this new form. The original form will still call this script include as well.



The script include is here:



var COMP_UserHelpers = Class.create();




COMP_UserHelpers.prototype = {


  initialize : function() {


  },



  showInactive : function(gr){


  //Check to see if current.u_show_termed_users is true or false, if FALSE return only active users (through filter)


  if (!gr.u_show_termed_users) {


  return 'active=true';


  }


  return ''; // send empty string (not null)


  },


   


  type: 'COMP_UserHelpers'


};


You can use glideRecord API to access that table and then set the field in the same script include..refer below link :


http://wiki.servicenow.com/index.php?title=GlideRecord#gsc.tab=0