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 SObjectModel.Facture();
var factureReferenceField = document.getElementById('facture-reference');
var factureClientField = document.getElementById('select-client');
facture.Reference__c = factureReferenceField.value ;
facture.Client__c = factureClientField.value;
console.log(facture);
Visualforce.remoting.Manager.invokeAction(
//Invoking controller action getcon
'{!$RemoteAction.TestController.saveFacture}',
facture, factureLines,
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 saveFacture(Facture__c facture, Ligne__c[] lines) {
// Perform isUpdatable() 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 :
https://gist.github.com/davidgeismar/163f099df6d1c8d814d04eb76dffbcc6
How to fix this error and make my remote call work ?