09-28-2015 11:20 AM
Hi there guys ive been lurking for the last few weeks here but finally need to ask a question i cant find answerd. I have a client that has configured ACT pro v16 with custom fields thru the ACT GUI. Now im in the proccess of building a webconsole for them that will allow thier customer service team to access act without viewing everything. I already have it so they can add a contact into the database with thouse custom fields as follows.
act login is completed above Contact ctct = FW.Contacts.CreateContact(); ctct.Fields["REP", Act.Framework.MutableEntities.FieldNameType.Alias] = rep; ctct.Fields["TO", Act.Framework.MutableEntities.FieldNameType.Alias] = to; ctct.Fields["ROOM", Act.Framework.MutableEntities.FieldNameType.Alias] = room; ctct.Fields["PACKAGE", Act.Framework.MutableEntities.FieldNameType.Alias] = package; ctct.Fields["PRICE", Act.Framework.MutableEntities.FieldNameType.Alias] = price; ctct.Fields["type", Act.Framework.MutableEntities.FieldNameType.Alias] = cardType;
Now on the other side i want to be able to query those fileds one of the fileds is called "VERIFIED" in the main contacts area. i would like to be able to search by contacts who are in "PENDING" status and display thier contact data like follows.
Act.Framework.Lookups.CriteriaColumn actColumn = FW.Lookups.GetCriteriaColumn("TBL_CONTACT", "VERIFIED", true); Act.Framework.Lookups.Criteria[] actCriteria = { new Act.Framework.Lookups.Criteria(Act.Framework.Lookups.LogicalOperator.End, 0, 0, actColumn, Act.Framework.Lookups.OperatorEnum.EqualTo, "PENDING") }; Act.Framework.Lookups.ContactLookup actLookup = FW.Lookups.LookupContactsReplace(actCriteria, true, true); Act.Framework.Contacts.ContactList actContacts = actLookup.GetContacts(null); the following is the theory so it displays each item for each contact in pending foreach Contact cont in actContacts { @cont.name @cont.package *@ symbol is required for mvc Razor syntax to print }
Now my problem is it returns "Column is null" but if i change it to a standard column like BUISNESS_EMAIL it will work.
09-28-2015 12:30 PM - edited 09-28-2015 12:40 PM
I think your problem is here
Act.Framework.Lookups.CriteriaColumn actColumn = FW.Lookups.GetCriteriaColumn("TBL_CONTACT", "VERIFIED", true);
Custom fields almost always have a random number appended to their name, so I doubt the column is actually called "VERIFIED" in SQL. Standard ACT fields have preset column names, so it is safe to use them, but for custom fields, I would recommend that when trying to get the field descriptors, use the "Display Name" of the field
If just looking for one or two fields, I usually like to use filtercriteria rather than lookups. The code below should work for you.
ContactFieldDescriptor cfdVerified = GetCFD("VERIFIED"); ContactList lstContacts = ActApp.ActFramework.Contacts.GetContacts(null, new IFilterCriteria[] { new ComparisonFilterCriteria(cfdVerified, ComparisonFilterCriteria.Operation.Equals, "PENDING") }); if (lstContacts != null) { //.. Do something }
private ContactFieldDescriptor GetCFD(string displayName) { ContactFieldDescriptor[] arFd = ActApp.ActFramework.Contacts.GetContactFieldDescriptors(); foreach (ContactFieldDescriptor cfd in arFd) { if ((cfd.DisplayName.ToLower().Equals(displayName.ToLower()))) { return cfd; } } //Log error as necessary return null; }
09-28-2015 12:30 PM - edited 09-28-2015 12:40 PM
I think your problem is here
Act.Framework.Lookups.CriteriaColumn actColumn = FW.Lookups.GetCriteriaColumn("TBL_CONTACT", "VERIFIED", true);
Custom fields almost always have a random number appended to their name, so I doubt the column is actually called "VERIFIED" in SQL. Standard ACT fields have preset column names, so it is safe to use them, but for custom fields, I would recommend that when trying to get the field descriptors, use the "Display Name" of the field
If just looking for one or two fields, I usually like to use filtercriteria rather than lookups. The code below should work for you.
ContactFieldDescriptor cfdVerified = GetCFD("VERIFIED"); ContactList lstContacts = ActApp.ActFramework.Contacts.GetContacts(null, new IFilterCriteria[] { new ComparisonFilterCriteria(cfdVerified, ComparisonFilterCriteria.Operation.Equals, "PENDING") }); if (lstContacts != null) { //.. Do something }
private ContactFieldDescriptor GetCFD(string displayName) { ContactFieldDescriptor[] arFd = ActApp.ActFramework.Contacts.GetContactFieldDescriptors(); foreach (ContactFieldDescriptor cfd in arFd) { if ((cfd.DisplayName.ToLower().Equals(displayName.ToLower()))) { return cfd; } } //Log error as necessary return null; }
09-29-2015 06:32 AM
Thanks Ahsan!
That works awesome at returning the contacts but i cant figure out how to access the column data for the contact all i can get is the Contact name to show doing this:
ContactList cfdList = newPending(); foreach (var Data in cfdList) { @Data }
in theory i would like to accomplish something like this.
ContactList cfdList = newPending(); foreach (var Data in cfdList) { <td> @Data </td> <td> @Data.Email </td> <td> @Data.CustomField </td> etc.... }
once again thanks!
09-29-2015 01:17 PM
Once you have a ContactFieldDescriptor, you can use the GetValue method to return the value of that field for any Contact.
Example:
ContactFieldDescriptor cfdVerified = GetCFD("VERIFIED"); foreach (Contact contact in lstContacts) { object o = cfdVerified.GetValue(contact); //Check for null values. Convert to string or cast the object as necessary MessageBox.Show(o == null ? "" : o.ToString()); }
09-29-2015 01:22 PM
Yes thanks for your repsonse i just was in the proccess of typing that up i cant believe i didnt catcht that earlier.
Have a great day
Ryan Lewis