Uncaught Type Error: Cannot read property 'execute' of undefined

This discussion was created from comments split from: Uncaught+TypeError:+Cannot+read+property+‘execute’+of+undefined.

I’m facing the same exception, I have written javascript code on a button to call the apex class method.

Please find the script below,

var appMdel = skuid.model.getModel(‘Application’);
var appId = appMdel.data[0].Id;

var result = sforce.apex.execute(‘Button_Utility’,‘updateCollateralLeanAmount’,
appId : appId

The same script I have moved to another button is working as excepted. Please help me with this, why skuid is misbehaving like this.

Hi @SandyPanda

  • , thanks for bringing this issue to our attention.

    What version of Skuid are you using? Are you building in api v1 or v2?

  • Are there any differences between your two buttons? (e.g. a part of different components, in a popup, etc.)

Hi @“Anna Wiersema”
On every page, I do use the API version of V1 only and ngUI module. And my button is on the popup page. Please reply asap. I’m still having the same problem on many pages.

So basically, What i notice is sforce.apex.execute is working in custom skuid pages. But not in predefined or existing pages like i mentioned earlier ngUI module. Can you please do needful for me. Anyone, please reply.

Hey @SandyPanda, this sounds like this might be a namespace thing.

If the ngUI pages come from a managed package, and your custom Apex is coming from outside of the managed package, then you will have to specify the namespace when you’re targeting the Apex method.