i am getting this error on clicking a button. ---- A problem with the onclick javascript forthis button or link was encountered:{faultcode:'soapenv:Client',faultstring: No operation available for request {http://soap.sforce/schemas/package/close_date_updation} crUpdated, please check the WSDL for this}

Since i am new to java script please someone help me out.

My javascript code on button is-

//Call insertJob method by passing that Opportunity id 
sforce.apex.execute("Close_Date_Updation","crUpdated",{oppId:"{!Opportunity.Id}"} );

//Redirect to that tab 
window.location = 'https://ap2.salesforce.com/006/o';

My class & method is--

public class Close_Date_Updation
        public static void crUpdated(ID oppId)
          System.Debug('---------------->>>>>>>>>' + oppId); 
          List<Opportunity> opportunityList = [Select id,Master_Opportunity__c,Service_Start_Date__c,Revision_Date__c,CloseDate from Opportunity where id=:oppId];
          Map<Id, Opportunity> OppMap = new Map<Id, Opportunity>(opportunityList);
          List <Opportunity> childRecord = [Select id,Revision_Date__c,Service_Start_Date__c,CloseDate,Master_Opportunity__c from Opportunity where  RecordType.DeveloperName = 'Child_Opportunity' And Master_Opportunity__c IN: opportunityList];

          for(Opportunity ChildRecordObject : childRecord){ 

              opportunity opportunityObject = OppMap.get(ChildRecordObject.Master_Opportunity__c);  
                ChildRecordObject.Service_Start_Date__c = Date.valueOf(opportunityObject.Service_Start_Date__c).adddays(-1);
                ChildRecordObject.Revision_Date__c = Date.valueOf(opportunityObject.Revision_Date__c).adddays(-1);  
                ChildRecordObject.CloseDate = Date.valueOf(opportunityObject.CloseDate).adddays(-1);


            upsert childRecord;



1 Answer 1


For this sort of JavaScript to work, you need to expose your class as a web service by making these changes:

global class Close_Date_Updation {
    WebService static void crUpdated(ID oppId) {

See e.g. Apex in AJAX.

  • actually my classes are simple those i m using just to update my fields, actually i have tried to do it by trigger bt in trigger i had to update something but i don't want to update i just want to get done my work by clicking a simple button, why i need to write a webservice for that it's there in my system not in any outside system.
    – Sharma_raj
    Feb 12, 2016 at 9:19
  • if possible can you please tell me how to write a simple javascript to call this method by passing opportunity record id
    – Sharma_raj
    Feb 12, 2016 at 9:20
  • @RAT__ Your JavaScript looks correct to me. The problem is that your Apex class is missing the web service keywords that allow the class to be called from JavaScript, hence the error message that you get.
    – Keith C
    Feb 12, 2016 at 9:23
  • thanks Keith but still i am having doubt,if i am wrong please correct me, we used web service when we have to call a method from external system or can say application. then why i have to use webservice keyword in my class method's
    – Sharma_raj
    Feb 12, 2016 at 9:33
  • @RAT__ Salesforce chose to use the same mechanism - a web service - for this sort of button click as is used for exposing an API to an external system. In this case the browser is the "external system". This allows a requests to the server to be made without changing the overall page via a more normal HTTP GET/POST.
    – Keith C
    Feb 12, 2016 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .