Error: undefined is not a function.,Detail: undefined is not a function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 07:11 AM
Error: undefined is not a function.,Detail: undefined is not a function.
Getting the above error when try to test the Action in a flow which should fetch the API key from the API Key Credentials table through script include.
the script i'm writing in the action to fetch the API key from the script include
return (new global.ScriptIncludename().functionname());
Note: the flow Action was in Scope application and the Script include was written in global level
Can you please help me out on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 09:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 12:47 AM
You are not initializing the script include correctly, and are missing some interpunction.
Try this:
var ScriptIncludename = Class.create();
ScriptIncludename.prototype = {
initialize: function() {},
functionname: function() {
var encrypter = new GlideEncrypter();
var apigr = new GlideRecord('api_key_credentials');
apigr.addEncodedQuery('name=***');
apigr.query();
if (apigr.next()) {
return (encrypter.decrypt(apigr.getValue('api_key'))) + "";
}
},
type: 'ScriptIncludename'
};
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 02:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 02:35 AM
@nikhitha24,
To be honest I'm not sure why it isn't working for you.
I just recreated the same in my instance, with the exact script I posted before, and the exact function call you provided, script include in global and action in scoped app and I'm getting the api_key as result just fine.
If you call the script include in a background script, are you getting a result then?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 02:57 AM
Yes background script is working and even when i test the action input step then also its working
But facing this error only when i test the whole action.