Lightning Components in Visualforce - Unable to read sobject
So after quite a bit more investigation, the workaround for this is to set an sobjectType attribute on the sobject prior to sending it to the server. Thus if I update my sendToServer method as follows:
sendToServer : function(cmp, ev) {
var action=cmp.get('c.SendAccount');
var acc=cmp.get('v.acc');
// set the sobjectType!
acc.sobjectType='Account';
action.setParams({'acc' : acc});
var self=this;
action.setCallback(this, function(response) {
self.actionResponseHandler(response, cmp, self, self.sentAccount);
});
$A.enqueueAction(action);
}
I don't get the error and I'm able to debug my SObject out on the server.
To re-iterate, this only seems to be an issue when the component is in a Visualforce page and has a lookup field populated. (As an aside, the same thing happens when I create the sobject client side, but I usually expect to have to specify the sobjectType there anyway).