Update does not work in SalesForce API

I am trying to update a record through the SalesForce API (Enterprise WSDL).

The code below does a fine, and the return saveResult says the operation was successful.

However, when I look in SalesForce, the record is not updated. The only thing I can think of is that I'm using the wrong identifier. But I have a five, checked it and checked again, and then checked again.

Has anyone encountered anything similar before? Alternatively, I will be so glad if someone can point out a dumb mistake, which I probably made somewhere :-)

sforce.Participant__c updateParticipant = new sforce.Participant__c(); updateParticipant.Id = participant.Id.Length == 15? participant.Id : participant.Id.Substring(0, 15); if (updateType == "pre") { updateParticipant.Manual_Download_Date__c = DateTime.Now; updateParticipant.Manual_Download__c = true; } else if (updateType == "post") { updateParticipant.Post_Class_Manual_Download__c = true; updateParticipant.Post_Class_Manual_Downloaded_Date__c = DateTime.Now; } sforce.SaveResult[] result = SFLib.sfdc.update(new sforce.sObject[] { updateParticipant }); if (result == null || result.Length <= 0) return false; else { if (result[0].success == true) return true; else throw new Exception("Update participant failed", new Exception(result[0].errors[0].message)); } 
+8
c # api salesforce
source share
2 answers

When using .Net to call the Update method in the API, you must explicitly specify the * fieldname__cSpecified * field. For example.

 updateParticipant.aDateField_StartDate__c = DateTime.Now; updateParticipant.aDateField_StartDate__cSpecified = true; 
+19
source share

Please support this answer in the salesforce community so that it is included in their API documents, and Support can be trained for such an issue. It took us only 2 months to figure this out.

https://success.salesforce.com/ideaView?id=0873A0000003e1bQAA

thanks

0
source share

All Articles