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
JohnWJohnW 

Unable to update text box

Code:
string strQueryData = "select Id,Field1__c, Field2__c from CustomObj__c Where Contact__c = '0033000000GsPwn'";
arQueryResult = o2.query(strQueryData);

if (arQueryResult.records == null) {
    strErrorMsg = "No records matched query parameters";
}
else
{
    arQueryResult.records[p].Any[1].InnerText = "true";
    arQueryResult.records[p].Any[2].InnerText = "'18 09 2006'";

 
I've created a custom field of type text. but i am unable to update this via the api. The code above  is a sample of what i am trying to do:-
 
(Field1 = Checkbox
Field2 = Text)

The Update works ok and reports no errors but if i query the object straight after the second field is not set where as the first one is set correctly, this is also mirrored by the salesforce frontend

Any help would be most appreciated,is there a special way of updating move than one field or is it that the field is not updateable?

benjasikbenjasik
I would proxy the request (Soapscope works well, as does something simple like tcptrace), and post the message details
JohnWJohnW

Cheers, I've figured out that if the text box is already populated then the update will work, but if the text box is empty them it won't work.

Any ideas as to a way around this?

SuperfellSuperfell
Probably because if it was empty to start with, it'll have an xsi:nil='true' attribute on it, and when you send it back, it'll still be there. When you set the field value, you should make sure to clear the attribute values.
JohnWJohnW
That sounds interesting how would is change taht attribute in the c# code, i've looked throught the QueryResult array and that doesn't seem to contain the "xsi:nil='true'" within it.
 
Where do i look for the xsi to change this.
 
Cheers
SuperfellSuperfell
Well the Any is an array of XmlElement, so something like
arQueryResult.records[p].Any[1].InnerText = "true";
arQueryResult.records[p].Any[1].Attributes.RemoveAll();
Personally, i think its just as easy and more robust to construct a new sObject instance for the update call, instead of fiddling with one fetched by query.
JohnWJohnW

Cheers Simon thats works

Pat WimberlyPat Wimberly
Thanks, I had the same problem. Here's the VB sub I used to access fields by name:

Private Sub ClearField(ByVal fieldName As String, ByVal fields() As System.Xml.XmlElement)
        If Not fields Is Nothing Then
            For i As Integer = 0 To fields.GetUpperBound(0)
                If fields(i).LocalName.ToLower().Equals(fieldName.ToLower()) Then
                    fields(i).InnerText = "true"
                    fields(i).Attributes.RemoveAll()
                End If
            Next
        End If
    End Sub