You need to sign in to do that
Don't have an account?
Marty Dorren
how to use fieldsToNull in for loop
Hi,
I need to update a field (not required) to null but I'm getting an invalid field error from the debugger when trying to save:
List<monthly_summary__c> MSUp = [Select Id, Billing__c from monthly_summary__c where Id IN : ListMSDelId];
for(monthly_summary__c MSUp2 : MSUp) {
MSUp2.setFieldsToNull = new string[] { 'billing__c' };
// MSUp2.Billing__c = null;
}
update MSUp;
Any suggestions? I coundn't find much in the way of sample code to do this.
Thanks
I need to update a field (not required) to null but I'm getting an invalid field error from the debugger when trying to save:
List<monthly_summary__c> MSUp = [Select Id, Billing__c from monthly_summary__c where Id IN : ListMSDelId];
for(monthly_summary__c MSUp2 : MSUp) {
MSUp2.setFieldsToNull = new string[] { 'billing__c' };
// MSUp2.Billing__c = null;
}
update MSUp;
Any suggestions? I coundn't find much in the way of sample code to do this.
Thanks
Is "setFieldsToNull" a field in your object, then use API Name i.e. __c.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm#i1421117
It's an array inside the sobject
I think, fieldsToNull is available only in saleforce API (ie, while using salesforce webservice from other platform)
Simply put, how do I update that field with a null value? <ARGH!>
MSUp2.billing__c = null;
debugging shows that the null function works after I issue it in my loop. The problem seems to be that the update function will NOT replace with a null value:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CreateBilling caused an unexpected exception, contact your administrator: CreateBilling: execution of BeforeUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id a1yM0000000WOtjIAG; first error: DELETE_FAILED, Your attempt to delete B-001604 could not be completed because it is associated with the following monthly summaries.: MS-003273 : []: Trigger.CreateBilling: line 278, column 1
Even though null works, update() does not. ARGH 2x
Marty