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

nikhitha24
Tera Guru

@Ankur Bawiskar , @piyushsain and @Peter Bodelier 

 

Please check my reply in the above post

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.

@Peter Bodelier 

 

It's still the same, have attached the error logs please check the sameerror.png

Peter Bodelier
Giga Sage

@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.

@Peter Bodelier ,

 

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.