Community
Showing results for 
Search instead for 
Do you mean 
Reply

Error Setting Contact Field Value in Code

Copper Contributor
Posts: 51
Country: United States

Error Setting Contact Field Value in Code

I am continuing my work getting a VB application to directly read and write to an ACT database using the Framework.  I am getting the following error when attempting any of a number of approaches to address a field in Contacts:

 

Invalid name format: JOBTITLE parameter name: realName

 

In the code below the line marked "Attempt 1" does work while the line marked "Attempt 2" throws the error.  It seems clear that I can write directly to the tablename.fieldname specification but I would like to use the shorter fieldname specification.  Any help will be appreciated.

 

Public Class Form1

 

  '* Declare Framework object and login string used throughout

   Dim ActFwk As New Act.Framework.ActFramework

  Const ACTPadFile As String = _

    "C:\Users\Public\Documents\ACT\ACT for Windows 12\Databases\ACT2010Demo.pad"

 

  Private Sub btnAddContact_Click(ByVal sender As System.Object, _

    ByVal e As System.EventArgs) Handles btnAddContact.Click

    '*********************************************************************

    '* Create a new ACT contact from information on the form.

    '* Return the new contact ID to a label on the form

    '*********************************************************************

 

    '* Login to the sample database using default administrator

    ActFwk.LogOn(ACTPadFile, "Chris Huffman", "")

 

    '* Create and configure new contact

     Dim actCont As Act.Framework.Contacts.Contact

    actCont = ActFwk.Contacts.CreateContact

 

    With actCont

      .Company = txtCompany.Text

      .FullName = txtFirstName.Text &
" "txtLastName.Text

 

      '* Attempt 1 works

      .ContactFields(
"TBL_CONTACT.SPOUSENAME", True) = txtSpouseName.Text

 

      '* Attempt 2 throws error 

      .ContactFields("Contact.JOBTITLE", False) = "Test Title"

 

      '* The two attempts below also threw the same error

      '.Fields.Item("SpouseName", False) = txtSpouseName.Text

 

      '.Fields("Contact.SpouseName", False) = txtSpouseName.Text

 

      '* Record contact in ACT DB and retrieve new ID and

      '* parsed name elements

      Try

        .Update()

        lblContactID.Text = .ID.ToString

        lblFirstName.Text = .FirstName

        lblLastName.Text = .LastName

 

      Catch ex As Exception '* Something unexpected happened

        MessageBox.Show(ex.Message, "Get Your Credit Card Out", _

          MessageBoxButtons.OK, MessageBoxIcon.Hand)

 

      Finally '* Logoff regardless of success or failure

        ActFwk.LogOff()

 

      End Try

    End With

 

End Sub

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Error Setting Contact Field Value in Code

Not to sound funny but I usually just use a variable for table name so something like what you have turns into:

 

 Dim C As String

C="Table_Contact" 

 

Then my usage becomes: 

.ContactFields(C & ".JOBTITLE"False) = "Test Title" 

 

I only do this because I'm crazy about reducing misspelling with any strings I have in code (also it's easier to localize).

 

Is this like something you are looking for? 

Copper Contributor
Posts: 51
Country: United States

Re: Error Setting Contact Field Value in Code

[ Edited ]

I could use it, but what I am really looking for is the syntax to use when you don't want to use the full TableName.ColumnName syntax.  The documentation indicates that there are THREE different syntax approaches for addressing a field.  The TableName.ColumnName approach needs the IsReal property set to True and the other seem to use different naming schemes.  I'll probably just be resigned to using the full TN.CN specificatin since it works reliably.

 

Thanks.

 

[Edited to correct important typo.]

Message Edited by lwestatbus on 06-01-2010 02:02 PM
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Error Setting Contact Field Value in Code

Allen,

What about spill over tables?

If you loop thru the field descriptors doesn't the ColumnName return the spill over tablename rather then the TBL_CONTACT?

 

Thanks

-- Jim Durkin

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Error Setting Contact Field Value in Code

Yeah - this is why you don't see this in the generic controls I post here - spill over tables are a problem. 

 

If you use intellisense it'll show the overrides for that method  and should tell you what you need to provide.