You need to sign in to do that
Don't have an account?
rschenkel
API upsert - Custom fields
I’m using the upsert command to update Account records. I am updating standard and custom fields. All standard fields are being updated successfully as are textual (string) and picklist custom fields. However, all custom fields of other types (double?, bool?, etc.) are not updating.
When dealing with non-textual data do I have to do something special?
Thanks.
http://community.salesforce.com/t5/NET-Development/Why-is-my-date-number-boolean-being-ignored-for-create-and/td-p/4708
You need to set the specified flag to true
All Answers
Can you publish the code so that we can get a clear picture?
private bool UpdateAccount(string strCorpCode, string strPartnerPlan, string strName, string strJoinDate, string strAddress1, string strAddress2, string strCity, string strProvince, string strCountry, string strPostalCode, string strAreaCode, string strPhone, string strExtension, string strHowTheyFoundUs, string strBillingInformationSupplied)
{
double dCorpCode;
if (double.TryParse(strCorpCode, out dCorpCode) == false)
return false;
DateTime dJoinDate;
if (DateTime.TryParse(strJoinDate, out dJoinDate) == false)
return false;
bool bBillingInformationSupplied;
if (bool.TryParse(strBillingInformationSupplied, out bBillingInformationSupplied) == false)
return false;
try
{
Account[] accounts = new Account[1];
accounts[0] = new Account();
accounts[0].CorpCode__c = dCorpCode.ToString();
accounts[0].Partner_Plan_rdp__c = strPartnerPlan;
accounts[0].Name = strName;
if (String.IsNullOrEmpty(strAddress2) == true)
accounts[0].BillingStreet = strAddress1;
else
accounts[0].BillingStreet = strAddress1 + "\n" + strAddress2;
accounts[0].BillingCity = strCity;
accounts[0].BillingState = strProvince;
accounts[0].BillingCountry = strCountry;
accounts[0].BillingPostalCode = strPostalCode;
accounts[0].Phone = String.Format("{0}{1}{2}", String.IsNullOrEmpty(strAreaCode) ? "" : "(" + strAreaCode + ") ", strPhone, String.IsNullOrEmpty(strExtension) ? "" : " " + strExtension);
accounts[0].Join_Date_rdp__c = dJoinDate;
accounts[0].Billing_Info_Supplied_rdp__c = bBillingInformationSupplied;
accounts[0].How_They_Found_Us_rdp__c = strHowTheyFoundUs;
UpsertResult upsertResult = _sforceService.upsert("CorpCode__c", accounts)[0];
if (upsertResult.success == false)
{
// TODO: Log error
Error[] errors = upsertResult.errors;
return false;
}
return true;
}
catch (Exception e)
{
// TODO: Log error
return false;
}
}
CorpCode__c is a string, Partner_Plan_rdp__c is a picklist string, How_They_Found_Us_rdp__c is a picklist string. All of these update okay.
However Join_Date_rdp__c is a date and Billing_Info_Supplied_rdp__c is a Checkbox. These do not update.
Thanks, Rob
See the sticky in the .NET forum titled "why is my date/number/boolean being ignored"
Hi Simon,
Did you mean the post of your blog? From that I get I should do this?
accounts[0].Billing_Info_Supplied_rdp__c = bBillingInformationSupplied;
accounts[0].Billing_Info_Supplied_rdp__cSpecified = bBillingInformationSupplied;
Unfortunately that did not correct the problem.
http://community.salesforce.com/t5/NET-Development/Why-is-my-date-number-boolean-being-ignored-for-create-and/td-p/4708
You need to set the specified flag to true