Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I'm trying to update a record via the SalesForce API (Enterprise WSDL).

The code below executes fine, and the saveResult returned says that the operation was successful.

Yet, when I look in SalesForce - the record has not been updated. The only thing that I can think of is that I am using the wrong Id - But I have quintuple checked this and checked it again and then re-checked it.

Has anybody encountered something like this before? Alternatively, I will be so pleased if someone can point out the stupid mistake that I've 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;
            if (result[0].success == true)
                return true;
                throw new Exception("Update participant failed", new Exception(result[0].errors[0].message));

1 Answer

0 votes
by (32.1k points)
edited by

When you’re using .net to call the update method on the API, it is necessary to set the field *fieldname__cSpecified* explicitly.

Are you interested in learning Salesforce from scratch! Have a look at this interesting video on Salesforce provided by Intellipaat:

For example:

updateParticipant.aDateField_StartDate__c = DateTime.Now; updateParticipant.aDateField_StartDate__cSpecified = true;

Related questions

Browse Categories