+ Start a Discussion
alex.gan1.3933003770315437E12alex.gan1.3933003770315437E12 

can't update a checkbox field via SOAP API

I can't update a checkbox field(no error,but the checkbox field doesn't updated),code like this:

Account[] a= new Account[0];
a[0].Id = customer.Id;
a[0].Name = customer.Name;//textbox field is OK
a[0].Anyue_Membership__c = true;//checkbox field not be updated

            LimitInfo[] li;
            SaveResult[] sr;
            try
            {
                DebuggingInfo di = client.update(header, null, null, null, null, null, null, null, null, null, null, a, out li, out sr);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            if (sr[0].success == false)
            {
                foreach (Error error in sr[0].errors)
                {
                    returnValue += "errormessage:" + error.statusCode + error.message + "\t";
                }
            }
            return returnValue;

could anybody help me?
Best Answer chosen by alex.gan1.3933003770315437E12
alex.gan1.3933003770315437E12alex.gan1.3933003770315437E12
I get it,the field a[0].Anyue_Membership__cSpecified must be set to true whatever the checkbox is checked ot unchecked

Thanks

All Answers

Vinit_KumarVinit_Kumar
I don't see any update statement in your code,where are you updating the record ??
alex.gan1.3933003770315437E12alex.gan1.3933003770315437E12
Thanks for ur reply, Vinit_Kumar, here is the update statement:
try
            {
                DebuggingInfo di = client.update(header, null, null, null, null, null, null, null, null, null, null, a, out li, out sr);
            }

and Now I knew the reson why I can't update a checkbox field, I have to set it twice,like this:
a[0].Anyue_Membership__c = true;
a[0].Anyue_Membership__cSpecified= true;

Now I got a new question, I can update a checkbox field to "checked",but I can't update it to "unchecked" it,even I set them to false,like this:
a[0].Anyue_Membership__c = false;
a[0].Anyue_Membership__cSpecified= false;

I don't know why,could anybody help me?
Thanx!
alex.gan1.3933003770315437E12alex.gan1.3933003770315437E12
I get it,the field a[0].Anyue_Membership__cSpecified must be set to true whatever the checkbox is checked ot unchecked

Thanks
This was selected as the best answer
Gaurav NirwalGaurav Nirwal
You can use code Your problem can solved
Account[] a= new Account[0];
a[0].Id = customer.Id;
a[0].Name = customer.Name;//textbox field is OK
a[0].Anyue_Membership__c = true;//checkbox field not be updated

            LimitInfo[] li;
            SaveResult[] sr;
            try
            {
                DebuggingInfo di = client.update(header, null, null, null, null, null, null, null, null, null, null, a, out li, out sr);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            if (sr[0].success == false)
            {
                foreach (Error error in sr[0].errors)
                {
                    returnValue += "errormessage:" + error.statusCode + error.message + "\t";
                }
            }
            return returnValue;

Gaurav NirwalGaurav Nirwal
If your problem can't solved please change the line no. 10 By  this



DebuggingInfo di = client.update(header, null, null, null, null, null, null, null, null, null, null, a, out li, out sr);