06-25-2013 11:51 AM
I am nearly certain I've done this before but can't find the code, nor any other documentation.
I want the user to be able to choose a contact, using the standard "ACT! contact picker" dialog. I am pretty sure I can instantiate one and get a ContactList back from it.
Can someone recall where this is and point me to it?
Thanks,
Len
06-25-2013 02:16 PM - edited 06-25-2013 02:24 PM
Try this...
PublicSharedFunction GetContactListfromPicker(ByVal HostFramework As Act.Framework.ActFramework, _
ByVal SelectedContacts As Act.Framework.Contacts.ContactList) As Act.Framework.Contacts.ContactList
Try
'---------------------------------------------------------
' Create the default sort order
'---------------------------------------------------------
Dim FLD1 As Act.Framework.Contacts.ContactFieldDescriptor = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.LASTNAME", True)
Dim FLD2 As Act.Framework.Contacts.ContactFieldDescriptor = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.FIRSTNAME", True)
'Create a sort criteria array
Dim sort() As Act.Shared.Collections.SortCriteria
sort = New Act.Shared.Collections.SortCriteria() {New Act.Shared.Collections.SortCriteria(FLD1, System.ComponentModel.ListSortDirection.Ascending), New Act.Shared.Collections.SortCriteria(FLD2, System.ComponentModel.ListSortDirection.Ascending)}
'---------------------------------------------------------
' Get ACT's native 'Contact Picker
'---------------------------------------------------------
Dim oformPicker As Act.UI.Contacts.ContactPickerDialog = _
New Act.UI.Contacts.ContactPickerDialog(CommonPlugin.ACTAPP, _
HostFramework.Contacts.GetContacts(sort), _
SelectedContacts)
oformPicker.SelectedContactRequired = True
oformPicker.Text ="Select Contacts"
'------------------------------------------
' Show the ACT ContactPickerDialog
'------------------------------------------
If oformPicker.ShowDialog() = Windows.Forms.DialogResult.OK Then
' return nothing cause nothign was selected
If oformPicker.SelectedContacts.Count = 0 Then
Return Nothing
Else
Return oformPicker.SelectedContacts
End If
Else
Return Nothing
EndIf
Catch ex AsException
Throw ex
End Try
EndFunction
-- Jim Durkin
06-25-2013 02:16 PM - edited 06-25-2013 02:24 PM
Try this...
PublicSharedFunction GetContactListfromPicker(ByVal HostFramework As Act.Framework.ActFramework, _
ByVal SelectedContacts As Act.Framework.Contacts.ContactList) As Act.Framework.Contacts.ContactList
Try
'---------------------------------------------------------
' Create the default sort order
'---------------------------------------------------------
Dim FLD1 As Act.Framework.Contacts.ContactFieldDescriptor = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.LASTNAME", True)
Dim FLD2 As Act.Framework.Contacts.ContactFieldDescriptor = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.FIRSTNAME", True)
'Create a sort criteria array
Dim sort() As Act.Shared.Collections.SortCriteria
sort = New Act.Shared.Collections.SortCriteria() {New Act.Shared.Collections.SortCriteria(FLD1, System.ComponentModel.ListSortDirection.Ascending), New Act.Shared.Collections.SortCriteria(FLD2, System.ComponentModel.ListSortDirection.Ascending)}
'---------------------------------------------------------
' Get ACT's native 'Contact Picker
'---------------------------------------------------------
Dim oformPicker As Act.UI.Contacts.ContactPickerDialog = _
New Act.UI.Contacts.ContactPickerDialog(CommonPlugin.ACTAPP, _
HostFramework.Contacts.GetContacts(sort), _
SelectedContacts)
oformPicker.SelectedContactRequired = True
oformPicker.Text ="Select Contacts"
'------------------------------------------
' Show the ACT ContactPickerDialog
'------------------------------------------
If oformPicker.ShowDialog() = Windows.Forms.DialogResult.OK Then
' return nothing cause nothign was selected
If oformPicker.SelectedContacts.Count = 0 Then
Return Nothing
Else
Return oformPicker.SelectedContacts
End If
Else
Return Nothing
EndIf
Catch ex AsException
Throw ex
End Try
EndFunction
-- Jim Durkin
06-28-2013 07:30 AM
Wow, thanks Jim! The only way that could have been better is if it was in C# (kidding!)
That dialog let me build a feature where a user picks a quote he's done in the past, click duplicate, pick the contact, and then create a copy of the quote and opportunity records and launch the editor. Their sales people will love it.
Thanks!!
06-28-2013 08:05 AM - edited 06-28-2013 08:08 AM
C# provided by http://www.developerfusion.com/tools/convert/vb-to-csharp/
public static Act.Framework.Contacts.ContactList GetContactListfromPicker(Act.Framework.ActFramework HostFramework, Act.Framework.Contacts.ContactList SelectedContacts)
{
try {
//---------------------------------------------------------
// Create the default sort order
//---------------------------------------------------------
Act.Framework.Contacts.ContactFieldDescriptor FLD1 = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.LASTNAME", true);
Act.Framework.Contacts.ContactFieldDescriptor FLD2 = HostFramework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.FIRSTNAME", true);
//Create a sort criteria array
Act.Shared.Collections.SortCriteria[] sort = null;
sort = new Act.Shared.Collections.SortCriteria[] {
new Act.Shared.Collections.SortCriteria(FLD1, System.ComponentModel.ListSortDirection.Ascending),
new Act.Shared.Collections.SortCriteria(FLD2, System.ComponentModel.ListSortDirection.Ascending)
};
//---------------------------------------------------------
// Get ACT's native 'Contact Picker
//---------------------------------------------------------
Act.UI.Contacts.ContactPickerDialog oformPicker = new Act.UI.Contacts.ContactPickerDialog(CommonPlugin.ACTAPP, HostFramework.Contacts.GetContacts(sort), SelectedContacts);
oformPicker.SelectedContactRequired = true;
oformPicker.Text = "Select Contacts";
//------------------------------------------
// Show the ACT ContactPickerDialog
//------------------------------------------
if (oformPicker.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
// return nothing cause nothign was selected
if (oformPicker.SelectedContacts.Count == 0) {
return null;
}
else {
return oformPicker.SelectedContacts;
}
}
else {
return null;
}
} catch (Exception ex) {
throw ex;
}
}
06-29-2013 04:53 PM
Hey, that's pretty sharp!
I understand VB.NET well enough since that's what I wrote before taking the ACT! SDK class back in '05 and converting to C#, but that's a neat tool. I still end up transposing some declarations when I'm reading VB, so that's helpful.
Thanks,
Len