How To: Get all Entity Field Values in a single string

Posts   
 
    
Posts: 116
Joined: 18-Feb-2006
# Posted on: 21-May-2006 21:22:26   

What I would like to do is retrieve all of the Field values for a specific entity and put it in a string (for logging purposes). I'm using the Self-Servicing model.

For example: I have a User Entity that has ID, Login, Name, LocationCode. I would like to retrieve the FieldName and the FieldValue from each assignable Field and put it in a single string. So the above User Entity would return the following string:

ID=24;Login=jcrede;Name=Joe Crede;LocationCode=CHISOX
Public Function GetEntityFieldValuesAsString(objEntity as Entity) as String
    Dim strReturn as New StringBuilder
    For Each objField as <Field> in <objEntity.Fields>
        strReturn.Append(objField.Name)
        strReturn.Append("=")
        Try
            strReturn.Append(CStr(objField.Value))
        Catch
        End Try
        strReturn.Append(";")
    Next
    Return strReturn
End Function

Is there a generic way to do this for every entity? I didn't know if there's already a build in function implemented in the EntityBase for this.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 21-May-2006 22:14:22   

Not sure if this helps, but there is something close: writeXML simple_smile . Can seem to see anything at entity level - I was looking for toString function at entity level, but this only exists at attribute level.