07-15-2010 08:49 AM
I have searched the Forum and the SDK documentation and I am having a hard time finding what I need. I have an application I am writing and all I am trying to do is edit some custom YES/NO fields. I would prefer to do this by CONTACTID which i am obtaining via the ACT Reader tool. HELP!
07-15-2010 10:08 AM - edited 07-15-2010 10:10 AM
You can retrieve a contact via ID like this:
Contact c = afw.Contacts.GetContactsByID(myID);
Once you've captured the contact you can update their fields either by capturing the FieldDescriptor for your field and then calling the SetValue method for the field.
ContactFieldDescriptor YesNoContactField = ActApp.ActFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.CUST_YesandNo_020852428");
Contact contact = ActApp.ApplicationState.CurrentContact;
Or by using the contact's field property and assigning a value
c.Fields["YourFieldName", true] = true;
07-15-2010 11:44 AM - edited 07-15-2010 11:45 AM
You'd need to add a reference to Act.Framework.dll, Act.Shared.Collections and then imports statements for Act.Framework and Act.Framework.Contacts. If this is a framework application you'll also need to create an instance of the ActFramework object and call it's LogOn method.
Once your logged onto the framework you'll have the access you need to do what you've described.
I think I also may have left off some of the parameters from the GetContactsByID method, should be GetContactsByID(sortCriter(), contactKeys(), ContactList).
The one's where you see ActApp.ActFramework look that way because it was done in a plug-in rather than a framework applicationi, you'd just replace ActApp.ActFramework with your instantiated ActFramework object.
07-15-2010 11:50 AM
07-15-2010 11:52 AM
I have everything I need imported. And I can access what you are talking about but I get errors and I do not believe I am writing the statement correctly. Lets say I have an ID:
I just want info for that single Contact ID.
I have this, what am I missing?
Dim ActFwk as new Act.framework.Actframework
Actfwk.Logon(user, Pass, Host, DB)
Obviously that is not correct.
07-15-2010 12:53 PM
It's throwing build errors likely because there is no method that accepts parameters of that type.
The best match would be GetContactByID(sortCriter() As Act.Shared.Collection.SortCriteria, contactKeys() As System.Guid) in other words you need a collection of sort criteria (or Nothing) and a collection of Guid's. You can create a collection of Guid's like:
Dim guid As Guid = New Guid("063551df-33b0-4141-b415-6628dd49e3a2")
Dim contactKeys(1) As Guid
contactKeys(0) = guid
At this point you have both of the parameters required to get your contact by ID:
Dim ContactbyID = _afw.Contacts.GetContactsByID(Nothing, contactKeys)
As you type, if your in Visual Studio, intelliesense ought to be letting you know what parameters are required/acceptable as well as any potential overloads.
07-15-2010 01:18 PM
Thanks For all your help!! I am starting to understand how this works now. I just have one problem now. here is my code.
Dim guid As Guid = New Guid("063551df-33b0-4141-b415-6628dd49e3a2") Dim contactKeys(1) As Guid contactKeys(0) = guid Dim myRecordByID = ActFwk.Contacts.GetContactsByID(Nothing, contactKeys) Dim contactFields As ContactFieldDescriptor = ActFwk.Contacts.GetFieldDescriptor("CUST_ContactsTable1_111514.CUST_cert2010UHCAARPmapd_083502624") contactFields.SetValue(myRecordByID(0), True) myRecordByID.Item(0).Fields("CUST_ContactsTable1_111514.CUST_cert2010UHCAARPmapd_083502624") = True
It works fine until i get to the last line and it says Invalid Table Name. But i checked that is the table the data i want to change is in.
07-15-2010 01:36 PM
07-15-2010 01:37 PM
THANKS AGAIN FOR THE HELP!!! I have it working here is the code for anyone else trying to do the same thing.
Dim guid As Guid = New Guid("063551df-33b0-4141-b415-6628dd49e3a2") Dim contactKeys(1) As Guid contactKeys(0) = guid Dim myRecordByID = ActFwk.Contacts.GetContactsByID(Nothing, contactKeys) Dim contactFields As ContactFieldDescriptor = ActFwk.Contacts.GetFieldDescriptor("CUST_ContactsTable1_111514.CUST_cert2010UHCAARPmapd_083502624") contactFields.SetValue(myRecordByID(0), True) myRecordByID.Item(0).Update() ActFwk.LogOff()