Community
Showing results for 
Search instead for 
Do you mean 
Reply

Retrieve table name for querying by display name

New Member
Posts: 10
Country: Ireland

Retrieve table name for querying by display name

Hi Guys

 

Stuck again!  Im trying to find out the "friendly" (not sure what its called) name of a table so I can query contact information using the column display name.  For eg:

 

Field = ActFwk.Contacts.GetContactFieldDescriptor("Contact.My Custom Field", False)
Value = Field.GetValue(cContact)

 

Which works fine for all fields in the Contact table, and this also works for the secondary contacts table VWT_SECONDARY_CONTACT:

 

Field = ActFwk.Contacts.GetContactFieldDescriptor("Secondary Contact.My Custom Field", False)
Value = Field.GetValue(cContact)

 

I just guessed it was Secondary Contact, but I dont want to really guess, I would rather access the correct name via a property, as I have fields that have spilled over to a custom table, which is named CUST_ContactTable1_123616, and who knows, once thats full there maybe another custom table

 

Hope Ive explained that ok, Im fairly confused...thanks!

 

Cheers

Mark 

Tuned Listener
Posts: 11
Country: Switzerland

Re: Retrieve table name for querying by display name

[ Edited ]

Hi

 

I solve this kind of problem by using a in-memory list of display names and "physical" names of the fields in a table:

 

Public Class ACTFieldNames

Private Shared DisplayNameFieldList As New Collections.Specialized.StringDictionary

Public Shared Function GetCachedPhysicalFullFieldNameFromDisplayName( _

ByVal sDisplayFieldShortName As String,

ByVal TableType As Act.Framework.RecordType

) As String

 

Dim Key As String = TableType.ToString & "!!!" & sDisplayFieldShortName
If DisplayNameFieldList.ContainsKey(Key) Then

'cache hit

Return DisplayNameFieldList(Key)
End If
Dim fld As Act.Framework.Database.FieldDescriptor = _
GetNonCachedPhysicalFullFieldNameFromDisplayName(sDisplayFieldShortName, TableType)
Dim Value As String = fld.TableName & "." & fld.ColumnName
DisplayNameFieldList.Add(Key, Value)

Return Value
End Function

 

Private Shared Function GetNonCachedPhysicalFullFieldNameFromDisplayName( _

ByVal sDisplayFieldShortName As String,

ByVal TableType As Act.Framework.RecordType

) As Act.Framework.Database.FieldDescriptor

Dim flds As Act.Framework.Database.FieldDescriptorCollection = _
ACT_SQL.ACTFramework.Fields.GetFields(TableType)
Return flds.Item(sDisplayFieldShortName)
End Function

End Class

Message Edited by rscherrer on 05-23-2008 03:21 PM
Reto Scherrer
Ambit AG
Switzerland
New Member
Posts: 10
Country: Ireland

Re: Retrieve table name for querying by display name

Hi Reto

 

Works like a charm - exactly what I needed!

 

Thanks a million!