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
EUSEUS 

webservice method called from another webservice method error...

Hi,

 

I am trying to call a webservice method from whithin another webservice method from other class. I have tested the werbservices on Developer Console  and work fine. However the Apex code does not compile when adding the call from a webservice method class. Is there any restrinctions I am not aware of?

Here follows the webservices code:

 

 webservice static string batchTrxnLoadValidaion() {
             
    List<TRXN__c> oTxIt =
    [SELECT tx.Name, tx.Amount__c, tx.Type__c, tx.IMEI_IMEISV__c, tx.Mrch_Contract__c   
      FROM TRXN__c tx
      WHERE tx.id IN : Trigger.new 
      FOR UPDATE]; 
    for (TRXN__c Trx : oTxIt)   {
           id trxMember = Member.getMember(Trx.Mrch_Contract__c);
      //  more code here  .....

  

 

This is the Force.IDE message I get:

Save error: Method does not exist or incorrect signature: [String].getMember(String)

 

If I remove this statement the webservice compiles ok.

 

The method called getMember() follows:  (BTW: I tested it on Development Console and works fine)

 

 webservice static ID getMember(string mbContract) {
        ID mbMember = null;
        List<Member__c> activeMembers = [SELECT mb.Name, mb.Contract__c
                                         FROM Member__c mb WHERE mb.Status__c = 'Active'
                                         AND mb.Contract__c =: mbContract LIMIT 1];
        if (!activeMembers.isEmpty()) { mbMember = activeMembers[0].id;
                                      return mbMember;             
        }
        else { return null; }
   } 

 

Thanks for your help!

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Thomas DvornikThomas Dvornik

I was able to call a webservice method in a webservice method. 

 

From the error, it looks like it thinks Member is a string. Do you have a property called "member" in your class that has batchTrxnLoadValidation? (remember, apex is case-insensitive).

All Answers

Thomas DvornikThomas Dvornik

I was able to call a webservice method in a webservice method. 

 

From the error, it looks like it thinks Member is a string. Do you have a property called "member" in your class that has batchTrxnLoadValidation? (remember, apex is case-insensitive).

This was selected as the best answer
EUSEUS

Hi Thomas,

 

I had a  private static string Member  variable on the class containing the webservice method. You were right the variable took precedence over the "class Member" that I meant to call ! ... and it confused it.  I changed the variable name and it works now.

 

Thanks a lot!