Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Allowing custom contact fields to be searched View modes: 
User avatar
Certified Developer 9
Certified Developer 9
ast35 - 1/29/2014 10:09:38 AM
   
Allowing custom contact fields to be searched
I hope this is the right place in the forum to post this. I couldn't see an 'On-line marketing' section.

We have added additional custom fields to the OM_Contact system table, and we would like to be able to search on that in CMSDesk -> On-line marketing -> Contacts

When we edit the contacts, we can see the fields we have added in the 'Custom fields' tab, but it does not appear possible to search on the fields.

Is there something we are missing? I would appreciate any assistance.

Thanks in advance.

User avatar
Member
Member
kentico_sandroj - 1/29/2014 3:04:34 PM
   
RE:Allowing custom contact fields to be searched
Hello,

Unfortunately, the OM_Contact does not have the Search Fields tab enabled by default, as CMS_User for example, but it can be enabled.

You would first have to run a query similar to the following to enable the "Searchable" property for the OM_Contact table, in the CMS_Class table:
Update [CMS_Class]
SET ClassSearchEnabled = '1'
WHERE ClassID = 'YourClassID'

Please run a Select * on your CMS_Class table to get the correct class id for OM_Contact.

Once you have updated the ClassSearchEnabled field, please navigate to your project folder and make a change to the following file: ~\CMSModules\SystemTables\Pages\Development\SystemTable\Header.aspx.cs

The change that needs to be added is around line 69. You would have to add another case to the switch:
                case "om.contact":
tabs[3, 0] = GetString("systbl.header.search");
tabs[3, 1] = "SetHelpTopic('helpTopic', 'system_tables_search_full_fields_tab');";
tabs[3, 2] = URLHelper.EncodeQueryString("Edit_SearchFields.aspx?classname=om.contact");
break;

Once these changes have been made, the Search Fields tab will be available under Site Manager > Development > System Tables > [edit]OM_Contact > Search Fields.

Please let me know if you have additional questions or concerns.

Best Regards,
Sandro

User avatar
Certified Developer 9
Certified Developer 9
ast35 - 1/30/2014 5:35:03 AM
   
RE:Allowing custom contact fields to be searched
Hi, thanks for your reply.

I did that, and set the field to 'Searchable' in the new 'Search fields' tab, but in CMS-Desk-> Online Marketing -> Contacts, the Search form on the 'Contacts' tab has not been altered.

Is it possible to alter that form, or do I have to set up the search in some other way?

Thanks.

User avatar
Member
Member
kentico_sandroj - 1/30/2014 9:38:29 PM
   
RE:Allowing custom contact fields to be searched
Hello,

As per our e-mail conversation, it seems that differences in our terminology has caused some confusion. Searchable means enabling the Smart Search module to be able to look at the custom columns when looking for data. Sorting through the UniGrid under CMS Desk > On-line Marketing > Contacts would be considered Filtering. In order to add the custom columns to both the UniGrid, and as one of the filtering options, two files will have to be modified:

~\CMSModules\ContactManagement\Controls\UI\Contact\List.aspx
~\CMSModules\ContactManagement\Controls\UI\Contact\Filter.aspx

In the list file, you will first add the custom column to the UniGrid list of Columns on line 9:

<cms:UniGrid runat="server" ID="gridElem" ObjectType="om.contactlist" OrderBy="ContactLastName"
Columns="ContactID,ContactLastName,ContactFirstName,ContactEmail,ContactStatusID,ContactCountryID,ContactSiteID,ContactMergedWithContactID,ContactGlobalContactID, ContactCreated, TestColumn"
IsLiveSite="false" HideFilterButton="true" FilterByQueryString="true" RememberDefaultState="true" RememberStateByParam="issitemanager">


Then, you will add that column to the Grid, similar to the way other columns have been added in that same file:

                <ug:Column Source="TestColumn" Caption="Test" Wrap="false">
</ug:Column>


Once added, the column and its values should start appearing in the list of contacts.

Now to update the filter(.aspx), you would add an additional label and TextSimpleFilter:

<tr>
<td>
<cms:LocalizedLabel ID="lblTestColumn" runat="server" ResourceString="test"
DisplayColon="true" EnableViewState="false" />
</td>
<td>
<cms:TextSimpleFilter ID="fltTestColumn" runat="server" Column="TestColumn" />
</td>
</tr>


You can set the visibility for both to Enabled, or you can set some logic in the codebehind (Filter.ascx.cs Page_Load) if needed:

        lblTestColumn.Visible = true;
fltTestColumn.Visible = true;


You would also update the GenerateWhereCondition() method on around line 385 to include the additional where condition:

 whereCond = SqlHelperClass.AddWhereCondition(whereCond, fltFirstName.GetCondition());
whereCond = SqlHelperClass.AddWhereCondition(whereCond, fltLastName.GetCondition());
whereCond = SqlHelperClass.AddWhereCondition(whereCond, fltEmail.GetCondition());
whereCond = SqlHelperClass.AddWhereCondition(whereCond, fltTestColumn.GetCondition());


Once all these changes have been made, you should have the ability to see and filter with your custom columns. Also, instead of using "test" as the ResourceString, you will likely want to create a custom resource string.

However, if the idea here is to get a list of contacts for reporting\exporting purposes, using the Reporting Module would be more appropriate.

You could create a custom report which allows you to define a custom set of parameters (your custom columns) then export the data in any of the available formats (XML, CSV, etc):

New Report
Report Parameters
Exporting Reports

Please let me know if you have additional questions.

Best Regards,
Sandro