Error: undefined is not a function.,Detail: undefined is not a function.

nikhitha24
Tera Guru

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

 

 

 

14 REPLIES 14

piyushsain
Tera Guru
Tera Guru

Hi Nikitha,

 

Please check are there any parameters present in the input of the function and add those parameters while calling the function, this can be the only reason . If the issue still persists please share the SI code

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

Ankur Bawiskar
Tera Patron
Tera Patron

@nikhitha24 

are you sure script include is getting called?

Are you sure there is no error coming in script include?

try adding try catch block to handle exception and check

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Peter Bodelier
Giga Sage

Hi @nikhitha24,

Can you share you script include and action?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

nikhitha24
Tera Guru

Hello,

 

the script include is getting called , when i test the input step then i'm getting the status code 200 the error is only getting when i'm trying to test the whole Action

 

here is the Action and the script include i have written

 

Action:

action rest.pngscriptinclude_calling.png

 

Script Include:

 

var  = 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'
};
 
Script Including Calling in Flow Action:
 
return (new global.ScriptIncludename().functionname());