Issue with Value returned from Script Include
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 01:10 AM
Hi,
I am calling a script include function from background script . The value returned from script include is coming as [object Object].However when I add log in script include, it is actuialluy a string.
Please let em know what is missing here.
Script include
var TestPageNameUtil = Class.create();
TestPageNameUtil.prototype = {
initialize: function() {},
myPagetester: function() {
var referer = GlideTransaction.get().getRequest().getHeader("referer");
var ty = JSON.stringify(referer);
gs.info("the sc messge is : " + ty);
return ty;
},
type: 'TestPageNameUtil'
};
Background script:
var ty = new global.TestPageNameUtil();
ty.myPagetester();
gs.info("the tester page is : " + ty);
Here is the output:
*** Script: the sc messger is : "https://dev266933.service-now.com/sys.scripts.modern.do"
*** Script: the tester page is : [object Object]
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 01:45 PM
Hi, to confirm the type of your variable you should use 'typeof'
JavaScript typeof (w3schools.com)
gs.info('My variable type ' + typeof yourVariable);