function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RRojoRRojo 

fieldsToNull Help in C#

I have a C# application written to fix our salesforce data.  I want to set the salutation field to null (if certain conditions are met) and then update the contact but nothing happens.

this is the code I'm using to set it to null (curr is a contact object from a query result).

curr.fieldsToNull = new string[] {"Salutation"};

Am I doing this right??

Message Edited by VDP-SForce Guy on 04-27-2004 09:48 AM

DevAngelDevAngel

Hi RRojo,

I'm not seeing any problems, this is how I do it.

 

String[] ftn = new String[] {"MobilePhone", "HomePhone", "work_Phone__c"};

contact.Id = "003300000037pzP";

contact.fieldsToNull = ftn;

sforce.SaveResult[] srs = binding.update(new sforce.sObject[] {contact});

for (int i=0;i<srs.Length;i++)

{

if (srs[i].success)

{

System.Windows.Forms.MessageBox.Show("Successfully updated contact.");

}

else

{

System.Windows.Forms.MessageBox.Show("Error - " + srs[i].errors[0].message);

}

}

zakzak
does the original object (curr) have data in the field you are trying to null ? if so, that will trump the fieldsToNull, you'll need to create a new contact object, set its Id and fieldsToNull and send that to update.

Cheers
Simon
DevAngelDevAngel
Good point zak.  I will verify this behavior.  It is not clear from the documentation what the behavior is when there are conficting instructions.