You need to sign in to do that
Don't have an account?
Error when testing Force.Com workbook example
Hi all,
I'm trying to work through the Force.com workbook and during the "Call an Apex Class Method Using a Button" example, after going through all the steps, when I click the button, I get an error:
{faultcode:'soapenv:Client', faultstring:'No operation available for request
{http;//soap.sforce.com/schemas/package/InvoiceUtilities}
renumberLineItems, please check the WSDL for the service.',}
In my developer instance, I tested the Apex code in the developer console and it returns successfully. I did research on google, and thought that it was either a permissions issue (I added everyone to the Apex class, no difference), or a Namespace prefix issue (i have namespace prefix 'bpavlyk;). I confirmed that a WSDL was generated.
The code is straight out of the workbook (pages 79-81) but with add of prefix bpavlyk__ to custom fields and objects.
Here is the Apex class:
global with sharing class InvoiceUtilities { // Class method to renumber Line Items for a given Invoice number. // Returns a string that indicates success or failure. webservice static String renumberLineItems(String invoiceName) { // create a copy of the target Invoice object and it's Line Items bpavlyk__Invoice__c invoice = [Select i.Name, (Select Name From bpavlyk__Line_Items__r ORDER BY Name) From bpavlyk__Invoice__c i Where i.Name = :invoiceName LIMIT 1]; // loop through each Line Item, renumbering as you go Integer i = 1; for (bpavlyk__Line_Item__c item : invoice.bpavlyk__Line_Items__r) { item.Name = String.valueOf(i); System.debug(item.Name); i++; } // update the Line Items in one transaction, rollback if any problems // and return error messages to the calling environment try { database.update(invoice.bpavlyk__Line_Items__r); } catch (DmlException e) { return e.getMessage(); } // on success, return a message to the calling program return 'Line items renumbered successfully.'; } }Here is the Javascript OnClick behind the button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{"invoiceName":"{!bpavlyk__Invoice__c.Name}"}); alert(result); window.location.reload();Thanks! I became angry like a buffalo trying to troubleshoot this... "O"