How can I access the Google Contact 'File As' field programmatically via the API?

457 views Asked by At

I desperately need to access this field in order to develop a Google Contacts sync tool that predominately utilizes the company name as the NAME or FILE AS field, NOT First/Last.

I see it in the XML but no dice via the libraries. I'm using the .NET library.

1

There are 1 answers

0
RyanMac On BEST ANSWER

I figured it out. Here's a little VB.NET code snippet in case anyone else needs to know how to manipulate values not directly exposed by the gData library. This returns the XML node (and creates first it if it doesn't exist). I actually change the value through the innerText property.

Private Function GetFileAsObject() As XmlNode

    For Each ext As Object In _contactEntry.ContactEntry.ExtensionElements
        If (ext.GetType() Is GetType(XmlExtension)) Then
            If ext.XmlName = "fileAs" Then
                Return ext.Node
            End If
        End If
    Next

    Dim doc As New XmlDocument
    doc.LoadXml("<gContact:fileAs xmlns:gContact='http://schemas.google.com/contact/2008'></gContact:fileAs>")

    Dim node As XmlNode = doc.DocumentElement
    Dim newExt As XmlExtension = New XmlExtension(node)

    _contactEntry.ContactEntry.ExtensionElements.Add(newExt)

    Return node

End Function

This link helped immensely: http://code.google.com/p/google-gdata/wiki/UnderstandingTheUnknown