0

I have created a custom button with following Onclick JS Code -

{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")} 
var Profile = "{!User.Profile}"; 
var OrderIds = "{! Order.Id }"; 
var OrderStatus = "{!Order.Status}"; 
if(Profile == "System Administrator") { 
if(OrderStatus == "Specific Status"){ 
var result = sforce.apex.execute("OrderLocking","lockOrder", 
{orderId:OrderIds}); 
location.reload(); 
} 
else { 
alert("Only specific Orders can be locked"); 
} 

} 
else { 
alert("You do not have the privileges to lock the order"); 
}

This is the class being called -

global class Orderlocking{


     webservice static void lockOrder(Id orderId)
     {
      Approval.LockResult lrList = Approval.lock(orderId, false);


    }
}

But on clicking the button I'm facing the below error -

faultcode:'soapenv:Client', faultstring:'No operation available for request

1

I believe this:

var result = sforce.apex.execute("OrderLocking","lockOrder", 
{orderId:OrderIds});

Needs to be

var result = sforce.apex.execute("Orderlocking","lockOrder", 
{orderId:OrderIds}); 

Case is important (notice the lowercase l in locking)

1
  • 1
    No idea why the makers of Apex decided to go for case insensitivity - it's caused no end of problems a bunch of devs who run into problems the moment they step into another language. – Caspar Harmer Apr 12 '17 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.