You need to sign in to do that
Don't have an account?
DJN
Updating a Boolean value in VBScript - seems to be ignored
Dear folks
I am trying to update some contact records, and it seems any attempt to update the boolean field values are ignored? (I can see various solutions for other environments, but none for VB). Basically I am assigning the fields with w_contact("fieldname").value = "New VAlue" for string fields, but I've tried any permutation of fields for the boolean values (eg True/False/1/0 etc) with no joy. THese fields are customer fields. I can read the values OK.
Can anyone tell me the secret?!
Thanks
DJN
Well that is odd, for sure.
About all I can do is try it from here. If you have a login with the object name and the field you are trying to set, email them to me and I’ll take a look.
Chopkins@salesforce.com
Thanks for your help so far... I'm really baffled now to be honest!! It seems to be working now.. I've really no idea why. I have made a test harness which ONLY does the bare minimum (my idea was to send you the same code sample for you to run at your end) and believe it or not it updates all correctly. So that really does suggest that the problem is being caused somewhere else, possibly the recordset connection to our data warehouse. Sorry for the trouble - once I get to the bottom of it I will let you know. Thanks for your interest in this problem anyway.... DJN
Just to confirm that this is indeed all OK. Bemused as to the cause but I now detect it is a boolean field, and directly assign true or false, and all seems to be OK. Thanks for your interest (and a great API).
DJN
I'm having the same issue using .Net and the enterprise wsdl. All numbers/boolean/date fields are ignored.No errors and all text/string fields go thru.
using (SforceService sfdc = new SforceService())
{
LoginResult lr = sfdc.login(ConfigurationSettings.AppSettings["NextGen.SalesForce.UserName"], ConfigurationSettings.AppSettings["NextGen.SalesForce.Password"]);
if (!lr.passwordExpired)
{
bool blnLocated = false;
sfdc.Url = lr.serverUrl;
sfdc.SessionHeaderValue = new SessionHeader();
sfdc.SessionHeaderValue.sessionId = lr.sessionId;
QueryResult qrLead = new QueryResult();
QueryResult qrContact = new QueryResult();
QueryResult qr = new QueryResult();
sfdc.QueryOptionsValue = new QueryOptions();
sfdc.QueryOptionsValue.batchSize = 250;
sfdc.QueryOptionsValue.batchSizeSpecified = true;
int pID = 31;
qrLead = sfdc.query("select id, IsConverted, ConvertedContactId, Do_you_currently_have_an_electronic_heal__c, Num_Providers__c, Company_name__c from Lead where NGC_ProfileID__c='" + pID.ToString() + "'");
if (qrLead.size > 0)
{
qr = qrLead;
blnLocated = true;
}
if (blnLocated)
{
for (int i = 0; i < qr.records.Length; i++)
{
Lead lead = (Lead)qr.records[i];
string strID = lead.Id;
sObject[] UpdateLink = new sObject[1];
if ((bool)lead.IsConverted)
{
//Contact uContact = new Contact();
//uContact.Id = lead.ConvertedContactId;
//uContact.Company_name__c = CompanyName.Length > 50 ? CompanyName.Substring(0, 50) : CompanyName;
//uContact.Position__c = Position.Length > 30 ? Position.Substring(0, 30) : Position;
//uContact.Company_URL__c = CompanyURL;
//uContact.Industry__c = IndType.Length > 50 ? IndType.Substring(0, 50) : IndType;
//if (PositionDesc != null)
//{
// uContact.Position__c = PositionDesc.Length > 30 ? PositionDesc.Substring(0, 30) : PositionDesc;
//}
//UpdateLink[0] = uContact;
}
else
{
Lead uLead = new Lead();
uLead.Id = strID;
uLead.First_name__c = "James"; //Works
uLead.Title = "Web Developer"; //Works
uLead.Position__c = "Web Developer"; //Works
uLead.Login_Enabled__c = true; // Ignored
uLead.Do_you_currently_have_an_electronic_heal__c = false; // Ignored
uLead.LeadSource = "Cold"; //Works
uLead.Num_Providers__c = 50; // Ignored
uLead.Practice_Specialties__c = "Anesthesiology; Asthma & Allergy"; //Works
UpdateLink[0] = uLead;
}
SaveResult[] sr = sfdc.update(UpdateLink);
for (int j = 0; j < sr.Length; j++)
{
if (sr[j].success)
{
//Console.Write(System.Environment.NewLine +
//"An account was created with an id of: " + sr[j].id);
}
else
{
//there were errors during the create call, go through the errors
//array and write them to the screen
for (int x = 0; i < sr[j].errors.Length; x++)
{
//get the next error
Error err = sr[j].errors[i];
Console.WriteLine("Errors were found on item " + j.ToString());
Console.WriteLine("Error code is: " + err.statusCode.ToString());
Console.WriteLine("Error message: " + err.message);
}
}
}
}
}
}
}