Community
Showing results for 
Search instead for 
Do you mean 
Reply

Trouble accessing custom fields

New Member
Posts: 33
Country: USA

Trouble accessing custom fields

Two custom fields, one works, the other does not when referencing them by their "Display Name".

The field "CIR - Up" is accessible.  The field "CIR - Down" is not.

 

I've attempted to follow suggestions provided in another post, but without much luck:

 

Contact currentContact = listManager.Current as Contact;

if (currentContact != null)

{

    contact_CIR_Up = currentContact.Fields["Contact.CIR - Up", false].ToString();

    contact_CIR_Down = currentContact.Fields["Contact.CIR - Down", false].ToString();

 

I have tried these as well...

 

    // contact_CIR_Down = currentContact.Fields["TBL_CONTACT.CUST_CIDDown_100200661", true].ToString();

    // contact_CIR_Down = currentContact.Fields["Contact Table 1.CIR - Down", false].ToString();

 

Looks like CIR - Down might be in a "Spillover" Table?

 
----------------------------------------------------------------------------------------------------
     ACT! Field: CIR - Down                                        ACT! Fieldtype: Character(50)
Physical Column: CUST_CIDDown_100200661                         Physical Datatype: NVARCHAR(50)
  OLE/DB Column: CONTACTS TABLE 1 CIR - Down
OLEDB(2) Column: [ContactsTable1_041817].[CIR - DOWN]
          Alias: CIR - DOWN
      Collation: Latin1_General_CI_AS
  Created On/By: Jan 26 2009 10:01AM / Joe Hollingsworth
         Custom: 1    Displayed: 1    Define Fields: 1    Ordinal: 44 
   Allow Blanks: 1      Primary: 0   Record History: 0
      Protected: 0   Can Resize: 1       Can Delete: 1
 Default Access: FULL ACCESS (2)    Valid Access Levels: 7 (NA RO FA)
    Access List: All Users(2)
  Initial Value:
       Picklist: CIR
    On Focus Trigger: None://
  Lost Focus Trigger: None://
   On Change Trigger: None://
----------------------------------------------------------------------------------------------------
 
Compare that to CIR - Up ...
 
----------------------------------------------------------------------------------------------------
     ACT! Field: CIR - Up                                          ACT! Fieldtype: Character(50)
Physical Column: CUST_CIR_074440375                             Physical Datatype: NVARCHAR(50)
  OLE/DB Column: CONTACT CIR - Up
OLEDB(2) Column: [CONTACT].[CIR - UP]
          Alias: CIR - UP
      Collation: Latin1_General_CI_AS
  Created On/By: Mar 20 2007  7:43AM / Jena St. Germaine
         Custom: 1    Displayed: 1    Define Fields: 1    Ordinal: 65 
   Allow Blanks: 1      Primary: 0   Record History: 0
      Protected: 0   Can Resize: 1       Can Delete: 1
 Default Access: FULL ACCESS (2)    Valid Access Levels: 7 (NA RO FA)
    Access List: All Users(2)
  Initial Value:
       Picklist: CIR
    On Focus Trigger: None://
  Lost Focus Trigger: None://
   On Change Trigger: None://
----------------------------------------------------------------------------------------------------
The only other tidbit is that these fields are defined on two different tabs, and there are two references each in the Properties window.  I think the intent was that if the field is updated on one tab, it updates the same field on the other tab.  This does seem to be working.  Not sure why.
Any ideas what I am missing here?
Thanks!
Jim
Nickel Elite Contributor
Posts: 937
Country: USA

Re: Trouble accessing custom fields

I think this is what you want:

 

contact_CIR_Down = currentContact.Fields["ContactsTable1_0418171.CIR - Down", false].ToString();

 

When you use the direct name (no alias) you have to refer to the complete table name.column name.  The spillover table is dynamically created and thus has a numeric in the table name itself.

New Member
Posts: 33
Country: USA

Re: Trouble accessing custom fields

Hmmm, tried it.  Now I am getting:

 

Act.Framework.MutableEntities.MutableEntityMetaDataArgumentException:

Invalid table name: ContactsTable1_041817

Parameter name: table

  at ...

 

I rechecked the ActDiag listing:

 

ACT! Field: CIR - Down ACT! Fieldtype: Character(50)

Physical Column: CUST_CIDDown_100200661 Physical Datatype: NVARCHAR(50)

OLE/DB Column: CONTACTS TABLE 1 CIR - Down

OLEDB(2) Column: [ContactsTable1_041817].[CIR - DOWN]

Alias: CIR - DOWN

 

and the source:

 

contact_CIR_Down = currentContact.Fields["ContactsTable1_041817.CIR - Down", false].ToString();

 

 

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Trouble accessing custom fields

I'm probably missing something as I'm replying between meetings but I think the string pass ref table name has to include [ ] if it includes spaces so try:

 

contact_CIR_Down = currentContact.Fields["[ContactsTable1_041817].CIR - Down", false].ToString();

New Member
Posts: 33
Country: USA

Re: Trouble accessing custom fields

Still no joy.

Whatever it is, I am missing it, too.

Silver Super Contributor
Posts: 2,328
Country: USA

Re: Trouble accessing custom fields

Change the false to true.

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
New Member
Posts: 33
Country: USA

Re: Trouble accessing custom fields

Hi Stan,

 

Tried that, too...

 

Act.Framework.MutableEntities.MutableEntityMetaDataArgumentException:

Invalid table name: [ContactsTable1_041817]

...

 

I've tried several variations:

 

 

 

 

contact_CIR_Down = currentContact.Fields["Contact.CIR - Down", false].ToString();

contact_CIR_Down = currentContact.Fields["Contact Table 1.CIR - Down", false].ToString();

contact_CIR_Down = currentContact.Fields["[ContactsTable1_041817].CIR - Down", false].ToString();

contact_CIR_Down = currentContact.Fields["[ContactsTable1_041817].CIR - Down", true].ToString();

contact_CIR_Down = currentContact.Fields["ContactsTable1_041817.CUST_CIDDown_100200661", true].ToString();

contact_CIR_Down = currentContact.Fields["TBL_CONTACT.CUST_CIDDown_100200661", true].ToString();

 

 

New Member
Posts: 33
Country: USA

Re: Trouble accessing custom fields

OK, after some gnashing and more trial and error, this one works:

 

contact_CIR_Down = currentContact.Fields["CUST_ContactsTable1_041817.CUST_CIDDown_100200661", true].ToString();

 

I am stll getting this the first time I enter the Contact View:

 

System.NullReferenceException: Object reference not set to an instance of an object.

  at Act.Configbutton.Configbutton.ContactChanged()

 

but I think that is due to this reference:

 

private void ContactChanged()

{

 

    try

    {

        if (listManager.Count > 0 && listManager.Position > -1)

        {

            Contact currentContact = listManager.Current as Contact;

 

...

Employee
Posts: 1,163
Country: USA

Re: Trouble accessing custom fields

The current contact may not be available at that point depending upon which event is triggering this code block.

 

It may be worth mentioning here that you'll always have access to the current contact via the application state.

 

ActApplication.ApplicationState.CurrentContact

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 33
Country: USA

Re: Trouble accessing custom fields

Allen, your take on this?