+ Start a Discussion
sfdcttslsfdcttsl 

Test Method for method calling in onclick javascript

Hi all,

 

Can anyone help me in solving the below scenario.

 

I have written an onclick javascript and called a method and passed one arguement into it.now i want to write a test method for the class which is declared as webservice.

 

/////JAVASCRIPT CODE////////

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var myvar = sforce.apex.execute("Insert_SSO_TimeManagement","insertSSO_TimeManagement",{oppID:"{!Opportunity.Name}"});

 

/////APEX CLASS/////

WebService static String insertSSO_TimeManagement(String oppID){

--

}

 

Please help me in writting the test method for the above class.

Best Answer chosen by Admin (Salesforce Developers) 
jd123jd123

Hi

 

 you can do directly 

 

1.first insert Opportunity

2.Decalre String s=oop.name;

3.call the Webservice method.

 

 

         YourClassName.insertSSO_TimeManagement(s);

 

IF your question is resolve please mark it as accept as a solution if not please let me know.

All Answers

jd123jd123

Hi

 

 you can do directly 

 

1.first insert Opportunity

2.Decalre String s=oop.name;

3.call the Webservice method.

 

 

         YourClassName.insertSSO_TimeManagement(s);

 

IF your question is resolve please mark it as accept as a solution if not please let me know.

This was selected as the best answer
sfdcttslsfdcttsl

We have tried the same but getting the below error.Plz look into this and suggest the way in resolving it

 

///The code which we added////

 

String s =opp2.Name;
 SSO_Time_Management__c timeManagement = new SSO_Time_Management__c(); 
 timeManagement.insertSSOTimeManagement(s);

 

///ERROR we got

 

Error: Compile Error: Method does not exist or incorrect signature: [SOBJECT:SSO_Time_Management__c].insertSSOTimeManagement(String) at line 72 column 3

 

 

72 line is the one which is in BOLD.

 

 

sfdcttslsfdcttsl

Thanks for the reply....

 

got the issue and got resolved!!!!!

jd123jd123

If your question is resolve please mark it as accept as a solution. Ifnot please let me know