function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
soasoa 

problem in invoking a Apex class from a Button

Hi,
 
I am Facing problem in invoking a Apex class from a Button. From one of our login I am able to invoke the class, but from the other I am not able to invoke the same class.
 
Is there any setting required for the same?
Please help me.
 
 
 
 
Regards
 
Diti
Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
Do you have a namespace set for your organization (e.g. for creating managed packages ?), if so you need to include this in the class name.

All Answers

learnSFlearnSF
Try to set security thorugh Salesforce use interface and add user to that class. I am not sure but I was getting error in page and later I add user in security,it solved my problem.
jlojlo
Have you enabled the Apex class for all of the appropriate Profiles? Setup > App Setup > Develop > Apex Classes > "Security" link next to each class.
soasoa

Hi,

I am still facing the same problem. I have enabled the apex class for  the appropraite profiles but still I am facing the same problem. 

The error which I am getting is:

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client',faultstring:'No service available for class 'InsertAcc',}

 

please help me.

 

Regards ,

Diti

jlojlo
Can you post the JS code that you're using to invoke the apex webservice?
 
What is the name of the webservice method? And the name of the Apex class?
soasoa
Hi,
 
The code for my Apex class is :
 
global class InsertAcc{
  WebService static Double InsertAccount()
  {
     insert new Account(name = 'Singha');
     Account acc = [select id from account where name = 'Singha' limit 1];
     String name = [select id, name from account where name = 'Singha' limit 1].name;
     Integer result = [select count() from account];
 
     
      return(result);
   }
}
 
}
 
The code for the Button is :
 
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
 
var result = sforce.apex.execute
(
"InsertAcc", // class
"InsertAccount", // method
{ //method arguments
}
);
alert (result);
 
 
The error which I am getting is:
 
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client',faultstring:'No service available for class 'InsertAcc',}
 
please help me.
SuperfellSuperfell
Do you have a namespace set for your organization (e.g. for creating managed packages ?), if so you need to include this in the class name.
This was selected as the best answer
PamSalesforcePamSalesforce

Hi,

 

Even i am facing the same problem.The code was working fine till i packaged it. I tried includin the name space but the error persists.

Please guide as to how to overcome this issue.

Imran MohammedImran Mohammed

Did you find a solution for this?