I am facing an error using javascript remoting Salesforce, what should I do?

364    Asked by Amitjaisawal in Java , Asked on Oct 10, 2022

I am trying to call a custom apex controller from javascript code in my visual force page but keep getting the following error :

 Visualforce Remoting Exception: No such column '_name' on sobject of type facture__c 
Here's the javascript call :
   var createFacture = function() {
          var facture = new Object Model.Facture();
          var factureReferenceField = document.getElementById('facture-reference');
          var factureClientField = document.getElementById('select-client');
          facture.Reference__c = factureReferenceField.value ;
          facture.Client _c = facture Client Field.value;
          console.log(facture);
        Visualforce.remoting.Manager.invokeAction(
            //Invoking controller action getcon
            '{!$RemoteAction.TestController.saveFacture}',
             facture, facture Lines,
            function(result, event){
                console.log("in callback func");   
                console.log(event.status);
                console.log(event.message);
            },
            {escape: true}
        );
         console.log('hell yeah');                          
      }

and here's the apex controller method Im trying to call :

@RemoteAction

public static Facture _c save Facture(Facture _c facturé, Ligne _c[] lines) {
    // Perform isUpdateable() checking first, then
    System.debug('facture: '+ facture);
    System.debug('lines: '+ lines);
    upsert facture;
    for(Ligne__c line : lines) {
        line.facture _c = facture.Id;
        upsert line;
    }
    return facture;
}

I ve made the full code of the page and the controller available on github if you need to see more : How to fix this error and make my remote call work?

Answered by Andrea Bailey

Regarding the javascript remoting Salesforce - apex:remoteObjects provides a JS-only interface; you can use this to perform DML operations and queries without Apex.

For a remote action method, you'd use a simple object:

var facture = { };
...
facture.Reference__c = factureReferenceField.value;
facture.Client _c = facture Client Field.value;
    Visualforce.remoting.Manager.invokeAction(
        //Invoking controller action getcon
        '{!$RemoteAction.TestController.saveFacture}',
         facture, ...


Your Answer

Interviews

Parent Categories