Community
Showing results for 
Search instead for 
Do you mean 
Reply

fully qualified real field name from display name

Copper Super Contributor
Posts: 52
Country: United_Kingdom

fully qualified real field name from display name

Hi everyone,

 

Here's a quick sample that gets a fully qualified real field name from display name. It comes in useful for most work with fields such as lookup, reading data and setting data.

 

Usage

Dim field As String = getRealField(oApp, "ID/Status", RecordType.Contact)

 

Return example

TBL_CONTACT.CATEGORY

 

I find it useful to use this in highly customized databases where new fields might be going to a spillover table and don't necessarily exist in TBL_CONTACT, TBL_COMPANY ect..

 

VB.net

 

Private Function getRealField(ByVal ActApp As ActApplication, ByVal DisplayName As String, ByVal RecordType As RecordType) As String
        Dim returnValue As String = ""

        Dim fields As FieldDescriptorCollection = ActApp.ActFramework.Fields.GetFields(RecordType)

        For Each field As FieldDescriptor In fields
            If field.Name = DisplayName Then
                returnValue = field.TableName + "." + field.ColumnName
            End If
        Next

        Return returnValue
    End Function

 C#

 

private string getRealField(ActApplication ActApp, string DisplayName, RecordType RecordType)
{
	string returnValue = "";

	FieldDescriptorCollection fields = ActApp.ActFramework.Fields.GetFields(RecordType);

	foreach (FieldDescriptor field in fields) {
		if (field.Name == DisplayName) {
			returnValue = field.TableName + "." + field.ColumnName;
		}
	}

	return returnValue;
}

 I hope this helps someone.

 

Regards,

 

 

Russell

 

Copper Super Contributor
Posts: 478
Country: Australia

Re: fully qualified real field name from display name

Thanks Russell

Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6