- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 03:18 PM
Is this possible? Can anyone point my to an example?
I assume the script include needs to be client callable and I would need to call this through GlideAjax, but I would need to set the function name, the parameters, etc., while it seems that only thing I can do in a sysparm_fixed_query is to specify an expression.
Thanks a lot!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2015 12:33 PM
Actually, I made it work in both environments: there was nothing wrong with the code, the problem was with the
sysparm_fixed_query - the type of the field was a Reference, not a String, and my test function was returning a string. This - somehow - caused SN to abort the the method call.
Thanks for your help, Cory!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 03:37 PM
Hi Laszlo,
You would treat a fixed query link any other query param. Here are a couple of examples:
&sysparm_fixed_query=opened_by=javascript:gs.getUserID()
&sysparm_fixed_query=sys_idINjavascript:new MyInclude().getSysIds()^active=true
You just make a regular script include. It doesn't need to be client-callable, nor have anything to do with GlideAjax. You set the fixed query in the URL of the list you are opening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2015 04:52 AM
Thanks, Cory, this is what I thought as well.
But on Eureka, when I try to call my AopHelper class' test() method by:
&sysparm_fixed_query=u_officer.u_supervisor=javascript:new AopHelper().test()
this is what I get in my sys log:
org.mozilla.javascript.EcmaError: "AopHelper" is not defined.
Caused by error in <refname> at line 1
==> 1: new AopHelper().test()
when I make AopHelper client-callable, I don't get this warning, but still doesn't work.
Any clue what's going on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2015 07:18 AM
I was wrong-the script include does have to be client callable to work in a query param.
What does the method return? Does it return a value if you call it directly in Scripts - Background? Are there any errors in the log when try to load a page with the filter and it is client callable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2015 08:37 AM
Thanks, Cory, for following up on this.
Here is the code of the test() method:
test: function()
{
gs.log("AopHelper.test method is called");
return "supervisor1";
}
If call this from a before-query business rule:
var s = new AopHelper().test();
gs.log("Value of s=" + s);
it works flawless, I see in the system log both
the "AopHelper.test method is called" message and the "Value of s=supervisor1" message.
So, this method is OK in a before-query business rule, but doesn't work in a query param. What can fix this?