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
uuuu 

Apex method call using custom button

Hii Friends,
Please help me.
The below javascript code on custom detail page button  shows error on click it.
--------------------------------------------------------------------------------------
{!REQUIRESCRIPT("/soap/ajax/47.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/47.0/apex.js")} 

var tempID='{!Offers_Appraisals__c.Id}';
if({!Offers_Appraisals__c.Id}!=Null)
{
sforce.apex.execute("NanoHRSheet","HRSalarySheet",tempID);
}
--------------------------------------------------------------------------------------
Error:
User-added image

What's wrong with code?
Please help me.
Thank you
Best Answer chosen by uu
AbhishekAbhishek (Salesforce Developers) 
Hi Anitha,

The blogs have similar queries and answers also provided in it.

Go through them once,

https://success.salesforce.com/answers?id=90630000000h7aMAAQ

https://salesforce.stackexchange.com/questions/172552/a-problem-with-the-onclick-javascript-for-this-button-or-link-was-encountered-m

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.

All Answers

AbhishekAbhishek (Salesforce Developers) 
Hi Anitha,

The blogs have similar queries and answers also provided in it.

Go through them once,

https://success.salesforce.com/answers?id=90630000000h7aMAAQ

https://salesforce.stackexchange.com/questions/172552/a-problem-with-the-onclick-javascript-for-this-button-or-link-was-encountered-m

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.
This was selected as the best answer
Prady01Prady01
Hi, I presume the way you are passing the parameter to the apex class might not be right.Below is an example.

 sforce.apex.execute("Approval_Class","approval_Method",{someid:"{!Record.Id}"});

 
global class Approval_class {
webservice static void approval_Method(Id someid) { 
// more logic
}

Hope this helps!
Prady01
uuuu
Thanks Prady01
It works:)

Regards
Anita Sodhi