I'm trying to update a checkbox field through lightning component and AuraEnabled method but,
When attempting to update checkbox field I get error 'invalid field for insert update bad field names on insert/update'
When I debug out the object being returned for update I get :
(Object__c:{checkbox_field__c=true, id=a2Cx0000000A4FED9})
But when I debug out the Object__C.checkbox_field__c from that object I get:
false
So, why can't I save, and why is this value seemingly being changed to false.
Apex controller:
public class customApexController{
@AuraEnabled
public static void saveObjects(List<object__c> objectDataList){
System.debug('saving objects:');
System.debug(objectDataList);
System.debug('object:');
System.debug(objectDataList[0]);
System.debug('checkbox_field__c:');
System.debug(objectDataList[0].checkbox_field__c);
System.debug('id:');
System.debug(objectDataList[0].id);
objectDataList[0].checkbox_field__c = true;
System.debug(objectDataList[0].checkbox_field__c);
update objectDataList;
}
Returns:
saving objects:
(Object__c:{checkbox_field__c=true, id=a2Cx0000000A4FED9})
object:
Object__c:{checkbox_field__c=true, id=a2Cx0000000A4FED9}
checkbox_field__c:
false
id:
a2Cx0000000A4FED9
true
System.DmlException: Update failed. First exception on row 0 with id a2Cx0000000A4FED9; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Object__c: bad field names on insert/update call: checkbox_field__c: [checkbox_field__c]
The method calling this is sending the objectDataList parameter as an array of objects with the object data like { Id: 'a2Cx0000000A4FED9', checkbox_field__c: true}