How to fix null return value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks 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
3 weeks ago
I did try, but no luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Ensure in your script include you are setting this checkbox as True
Sandbox enables - True
Client callable - True
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Omg I've been trying to solve this issue all day and changing Sandbox enabled to True fixed it for me! Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Hi @Supriya25 , recently i have done similar task .
Your Script Include is Client Callable
but this javascript:new global.getUserDetail().getBusinessUnit() - is a server-side execution.That is why it's returning NULL.
Remove : Client Callable checkbox (make sure that your script include is server side)
make sure that Script include All application scopes
important : Sandbox enabled to True
make sure enable snad
EX:
var getUserDetail = Class.create();
getUserDetail.prototype = {
getBusinessUnit: function() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addQuery('active', true);
gr.query();
if (gr.next()) {
return gr.getValue('u_business_unit');
}
return '';
},
type: 'getUserDetail'
};
call your script include
javascript:new getUserDetail().getBusinessUnit()
OR
javascript:new global.getUserDetail().getBusinessUnit()
If you found my solution helpful, please mark it as Helpful or Accepted Solution...!
thanks,
tejas
Email: adhalraotejas1018@gmail.com
LinkedIn: https://www.linkedin.com/in/tejas1018
