Skip to content

Instantly share code, notes, and snippets.

@sbob-sfdc
Created September 2, 2012 23:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sbob-sfdc/3605659 to your computer and use it in GitHub Desktop.
Save sbob-sfdc/3605659 to your computer and use it in GitHub Desktop.
Workshop 201, Tutorial 4, Step 1, Apex
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{invoice:"{!Invoice__c.Name}"});
alert(result);
window.location.reload();
@java-MagicWang
Copy link

Hi, I found a mistake ! The piece of code you distribute on this page is not corresponding with the force.com workbook. The third line parameter 'invoice' should be 'invoiceName'.

@fresh5447
Copy link

@java-MagicWang

I don't know how you found that, but I have been stuck on that issue for 2 days!

Thank you so much you rock!!!!

@SDSV
Copy link

SDSV commented Jul 24, 2014

Did this work for you guys.? as even on changing line "invoice" to "invoiceName", i still got an error related to SOAP WSDL error? Any idea where i could be going wrong.
and am non java person,so what would you suggest, how should i learn onclick javascript execution from SF. Thanks

@TheCrusader
Copy link

It's should be 'InvoiceName', JavaScript is case-sensitive. The complete codes as follows:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{InvoiceName:"{!Invoice__c.Name}"});
alert(result);
window.location.reload();

I use those codes and it works.

@scrubber9
Copy link

I used the complete code above and getting "No operation available for request {http://soap.sforce.com/schemas/package/InvoiceUtilities}renumberLineItems, please check the WSDL for the service" Any suggestions? Thanks.

@scrubber9
Copy link

Typo on my part and slightly different from above. Lowercase i in invoiceName.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{invoiceName:"{!Invoice__c.Name}"});
alert(result);
window.location.reload();

@cindynor
Copy link

I'm still getting the response: "please check the WSDL for the service".
What does this even mean?
I'm not a Java person and don't even know where to start to sort this out.
Too bad the workbook is so buggy... :-\

@dschach
Copy link

dschach commented Sep 16, 2014

Steve - I have the updated version here: https://gist.github.com/dschach/9c6445c39a5eca6e45d5/16a7926573f789ef1b51cfebefd97fc449c8b9ba
You may wish to update your gist from that.

@apocsve
Copy link

apocsve commented Oct 16, 2014

Well the code that worked for me was this:

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{"invoiceName":"{!Factura__c.Name}"});
alert(result);
window.location.reload();

If somebody need it.

@Bala81
Copy link

Bala81 commented Mar 30, 2015

Change the class type from public to global and method signature type from public to webservice

@sanjay-a3logics
Copy link

I have used all but not working alll

@sanjay-a3logics
Copy link

can you please help in this

@cmorganatsfdc
Copy link

@sanjay-a3logics

In the button code, "InvoiceUtilities" should be "invoiceUtilities" with small i for invoice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment