• Nao
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi All,

 

Has anyone ever expierenced this error when using Javascript Remoting?

 

Visualforce Remoting Exception: Method 'updateMerchantProduct' not found on controller ManageLeadsRemote. Check spelling, method exists, and/or method is RemoteAction annotated.

 

Serialzed Code:



global with sharing class ManageLeadsRemote {
   
    @RemoteAction
    global static sObject[] searchMerchants(String divisionName, string MerchantType) 
        {    
            //This Function Works 
        }
    
    
    @RemoteAction
    global static boolean updateMerchantProduct(String MerchantType, String recordID, String ProductLine) 
        {
        system.debug('------------------------DEBUG---if you can read this we got in to this function');
            boolean updateCheck = false;
            if(MerchantType=='Account')
                {
                    update new Account(Id = recordID, CurrentProduct__c = ProductLine);
                    updateCheck = true;
                }
            if(MerchantType=='Lead')
                {
                    update new lead(Id = recordID, CurrentProduct__c = ProductLine);
                    updateCheck = true;
                }
            return updateCheck;
        }

}

 Javascript Code in my VisualForce Page that enacts this method:

function updateAccount(MType, acc, newVal) 
    {
        // Javascript Remoting to update Accout record
        alert(MType);
        alert(acc);
        ManageLeadsRemote.updateMerchantProduct(MType, acc.Id, newVal, function(result, event)
            {         
               if (event.status && event.result) 
                   {       
                          alert('Good Job - this worked!');
                   } else 
                       {
                          alert(event.message);
                       }
            }, {escape:true});
    }

 

I have a feeling the error message that is being thrown is not the error that is actually occuring, the alerts are firing before the updateMerchantProduct remote function and are passing in the correct params. So I'm stuck on this....

 

Thanks!

  • September 14, 2011
  • Like
  • 0

Hi all,

 

I was faced some problem in dynamic InputField in repeat.

I found folution so I am going to share it in this discussion board.

 

To simplify, issue is like this.

 

-----in APeX:---

public myLead{set;get;}                                         //Lead record to be insert/update
public LIST<String> fieldNames{set;get;}          //List of field name 

 

//Constructor

public myPageControllerClass(){
    myLead = new Lead();
   

    fieldNames = new LIST<String>();
    fieldNames.add('firstName'); //dinamically show filed on VF page
    fieldNames.add('lastName');
}

 

---in VFpage Case A----(BAD)

<apex:repeat value="{!fieldNames}" var="fname">
    <apex:variable var="flabel" value="{!fname}"/>
    <apex:InputField value="{!myLead[flabel]}" />
</apex:repeat>

 

---in VFpage Case B----(GOOD)

<apex:repeat value="{!fieldNames}" var="fname">

    <apex:InputField value="{!myLead[fname]}" />
</apex:repeat>

 

Case A use VF value to store field name onece, then use it.

Case B don't use value

 

Both CAN display field value dynamically. It is fine.

 

However, in case A, editing in InputField CAN NOT change myLead record in APEX.

So if you put Action, then try to update myLead record in APEX function, no change will be saved :(

It is like onw way.

 

If you need to syncronize VF InputField and corresponding variable in APEX, use case B above.

 

I spend three days to solve this:(

Hope this helps someone, someday :)

 

Naoki Ueda @ Samurai System, Japan

 

  • September 12, 2013
  • Like
  • 0

Hi All,

 

Has anyone ever expierenced this error when using Javascript Remoting?

 

Visualforce Remoting Exception: Method 'updateMerchantProduct' not found on controller ManageLeadsRemote. Check spelling, method exists, and/or method is RemoteAction annotated.

 

Serialzed Code:



global with sharing class ManageLeadsRemote {
   
    @RemoteAction
    global static sObject[] searchMerchants(String divisionName, string MerchantType) 
        {    
            //This Function Works 
        }
    
    
    @RemoteAction
    global static boolean updateMerchantProduct(String MerchantType, String recordID, String ProductLine) 
        {
        system.debug('------------------------DEBUG---if you can read this we got in to this function');
            boolean updateCheck = false;
            if(MerchantType=='Account')
                {
                    update new Account(Id = recordID, CurrentProduct__c = ProductLine);
                    updateCheck = true;
                }
            if(MerchantType=='Lead')
                {
                    update new lead(Id = recordID, CurrentProduct__c = ProductLine);
                    updateCheck = true;
                }
            return updateCheck;
        }

}

 Javascript Code in my VisualForce Page that enacts this method:

function updateAccount(MType, acc, newVal) 
    {
        // Javascript Remoting to update Accout record
        alert(MType);
        alert(acc);
        ManageLeadsRemote.updateMerchantProduct(MType, acc.Id, newVal, function(result, event)
            {         
               if (event.status && event.result) 
                   {       
                          alert('Good Job - this worked!');
                   } else 
                       {
                          alert(event.message);
                       }
            }, {escape:true});
    }

 

I have a feeling the error message that is being thrown is not the error that is actually occuring, the alerts are firing before the updateMerchantProduct remote function and are passing in the correct params. So I'm stuck on this....

 

Thanks!

  • September 14, 2011
  • Like
  • 0