How to fix null return value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
Hi All,
Here I'm returning sysID from script include and calling that in table filler condition, but it is always showing null
Script Include : client callable ( Glide AJAX enabled) ,
All application scopes
Roles: public
getBuisnessUnit: function() {
var sysID = '';
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addQuery('active', true);
gr.query();
if (gr.next()) {
sysID = gr.getValue('u_business_unit');
}
//return sysID.toString();
return 'ac26c204870221003ff35d88e3e3ec61';
},
return 'ac26c204870221003ff35d88e3e3ec61'; testing Purpose just returning one sysid , even that also but still NULL value showing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Supriya,
I noticed in your screenshot that you are testing both scripts simultaneously using an OR condition.
This might be the cause. If the second script (getUserDetail - the Client Callable one) fails to parse correctly (because it extends AbstractAjaxProcessor, which is not friendly to List Filters), it can break the entire query, causing the system to return NULL even if the first script is correct.
Please try this exact single test:
Clear the filter completely.
Add only one condition (do not use OR).
Use the Server-Side script (the one that worked in Background).
Type manually: Sys ID | is | javascript:new getBusinessUnit().businessunit()
By removing the "Client Callable" script from the equation, you allow the valid script to run without interference.
If simplifying the filter solves it, please mark it as Accepted Solution.
Best regards, Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi ,
I did try that as well
background script :
gs.info("Server : " + new global.getBusinessUnit().businessunit());Result :
*** Script: Server : ac26c204870221003ff35d88e3e3ec61
Script Include :
var getBusinessUnit = Class.create();
getBusinessUnit.prototype = {
initialize: function() {},
businessunit: function() {
return '70c0b9c593fafe101a1bf6fa3d03d663';
},
type: 'getBusinessUnit'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Supriya,
Since the script works perfectly in the background, we need to perform one specific test to rule out a likely cause: Data Type Mismatch.
The Problem: The operator "is one of" technically expects a List/Array of values. Your script returns a single raw String.
The Test: Please change the operator in the filter from "is one of" to "is".
Why? Sometimes the filter parser fails to convert a single string return into the array format required by "is one of", resulting in NULL. By switching to "is", we align the operator with your exact return type (String).
Please try this single change and let me know the result.
Best regards, Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
I tried even , Array method also, still no use.
var getBusinessUnit = Class.create();
getBusinessUnit.prototype = {
initialize: function() {},
businessunit: function() {
var sysID = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addQuery('active', true);
gr.query();
if (gr.next()) {
sysID.push(gr.getValue('u_business_unit'));
}
// Ensure you return a String
return sysID.toString();
},
type: 'getBusinessUnit'
};
