Community
Showing results for 
Search instead for 
Do you mean 
Reply

Custom Fields for entering FistName and LastName directly

Tuned Listener
Posts: 6
Country: Belgium

Custom Fields for entering FistName and LastName directly

Hello,
 
I'm trying to create two custom fields (let's call them FN and LN) for direct input of FirstName and LastName (when creating a new contact or updating an existing one): when you have a database with, e.g., lots of Spanish names like Maria Isabel RODRIGUEZ TOQUERO Y RAMOS, the 3-dots button for setting FULLNAME parts is not very handy.
 
Could you suggest some stripped-down c# code for doing this?
 
Thanks in advance,
 
Roberto NATALE
 

 

Copper Contributor
Posts: 98
Country: United States

Re: Custom Fields for entering FistName and LastName directly

[ Edited ]
Hey Roberto,
 
If you are looking for a way to add a contact though the SDK and C# try this thread:
 
 
If you're looking for a way to add a contact FIELD though the SDK and C# try this:
 
//Inside your method

#region Lock DB

//Database MUST be locked before making Schema changes

ActFwk.Database.LockDatabase(Act.Framework.DatabaseLockReason.SchemaChanges);

#endregion

#region Create Field

//Create Field Object

Act.Framework.Database.FieldDescriptor Field;

//Create the Custom Field

Field = new FieldDescriptor("CustomField", Act.Framework.RecordType.Contact, Act.Framework.Database.FieldDataType.Character);

//Set the field's properties

Field.IsPrimary = false;

Field.IsTracked = true;

Field.AllowEmpty = true;

Field.Attributes[FieldProperty.Length] = new LengthAttribute(100);

//Important: You must save your changes

ActFwk.Fields.Save(Field);

#endregion

#region Unlock DB

//Don't forget to unlock your database after changes have been made

ActFwk.Database.UnlockDatabase();

#endregion



If for whatever reason your code errors out and your database is left in the 'locked' state. It can be unlocked via ActDiag.exe

ACT! 2006:

Start > Run > Type: Act8Diag > Ok

ACT! 2007+ :

Start > Run > Type: ActDiag > Ok

 

Go to the databases tab > Click the grey box to the left of your database > Right click and select 'Unlock Database'.

 



Message Edited by Carlton_Jones on 03-13-2008 10:50 AM
Carlton Jones
Sage Software
Tuned Listener
Posts: 6
Country: Belgium

Re: Custom Fields for entering FistName and LastName directly

Hello again,
 
Thanks for your reply, but I think I did not explain my case clearly enough.
What I meant is the following:
I define two new fields FN and LN through the menu TOOLS-->Define fields
I use the Layout Designer to add these two fields to my Contact Layout.
I go to the menu Contacts-->New Contact
I type 'John Edward' into the the FN textbox.
I type 'Smith' into the LN textbox
I click on the save button
The Contact textbox gets updated with the value 'John Edward Smith'
The First Name textbox gets updated with the value 'John Edward'
The Last Name textbox gets updated with the value 'Smith'
 
I want also to be able to update an existing contact from the LN and FN fields and also that when modifying the Contact textbox, the FN and LN fields are updated as well.
 
I  am trying to implement a c# plugin doing this (Act 10.0.1.199, SDK 9 or 10).
 
(At some point in my code I use this:

Contact currContact = ActApp.ApplicationState.CurrentContact;

currContact.ContactFields.FieldChanged += new Act.Framework.MutableEntities.MutableEntity.FieldCollection.FieldChangedHandler(ContactFields_FieldChanged);

in order to track changes on the FN or LN fields, but for some reason the changes to the FN and LN fields are not always reported.)
 
Could you suggest a way of doing this?
 
Thanks in advance,
 
Roberto NATALE
 
 
Copper Contributor
Posts: 98
Country: United States

Re: Custom Fields for entering FistName and LastName directly

[ Edited ]

Are you tracking changes to individual fields or any change to the contact fields?



Message Edited by Carlton_Jones on 03-14-2008 09:36 AM
Carlton Jones
Sage Software
Tuned Listener
Posts: 6
Country: Belgium

Re: Custom Fields for entering FistName and LastName directly

Hello, I want to track changes to individual fields (FN and LN, but they are also custom contact fields, isn't it?). If the user changes FN or LN, I want to update the contact. My problem is getting a way to relate a change on a control (the one linked to the custom field: I can retrieve a list of all the controls by looping on all controls in the Contacts View form) to the custom field itself (as defined in the Layout Designer). How do I know whether a given control corresponds to a specific custom field? I was exploring the possibility to do this through a plugin, but also through a custom control (but how do I get a reference to the ActApplication instance from within a custom control?). Maybe I am not looking in the right direction? Regards, Roberto NATALE