Quantcast
Channel: Customer FX
Viewing all articles
Browse latest Browse all 981

Globally filtering the Notes/History tab in the SalesLogix web client

$
0
0

 

In the SalesLogix web client, the Notes/History tab is largely based on client side binding.  The client side scripting handles the various functions the grid can perform like filtering.  One request I had recently is to globally filter the grid to exclude certain records regardless of what filers the users selected.  Now modifying the client side scripting could handle this, we can also do it a different way.

On the code file for the Notes History control (NotesHistoryList.ascx.cs) we see there is a OnFormBound event which is used to register a client side script onto the page:

 

protected override void OnFormBound()
   {
       base.OnFormBound();
       ScriptManager.RegisterClientScriptInclude(this, GetType(), "NotesHistoryList",
           Page.ResolveUrl("~/SmartParts/History/NotesHistoryList.js"));

       string scr = string.Format("Sage.UI.Forms.HistoryList.HistoryTypeMap = {{{0}}};", Server.HtmlEncode(BuildHistoryTypeMap()));
       ScriptManager.RegisterStartupScript(this, GetType(), "historyTypes", scr, true);

       var script =
           String.Format(
               @"window.setTimeout(function() {{ Sage.UI.Forms.HistoryList.init('{0}',
                   function() {{ return '{2} eq \'' + Sage.Utility.getCurrentEntityId() + '\''; }},
                   {{ workspace: '{1}', tabId: '{3}' }}); }}, 1);",
               placeholder.ClientID, getMyWorkspace(), GetParentField(), ID);

       if (!Page.IsPostBack)
       {
           script = string.Format("dojo.ready(function() {{ {0} }});", script);
       }
       ScriptManager.RegisterStartupScript(this, GetType(), "HistoryList_Init", script, true);
   }

If we modify the portion shown highlighted above we can pass in an additional criteria like so:

var script =
            String.Format(
                @"window.setTimeout(function() {{ Sage.UI.Forms.HistoryList.init('{0}',
                    function() {{ return '{2} eq \'' + Sage.Utility.getCurrentEntityId() + '\' and ({4})'; }},
                    {{ workspace: '{1}', tabId: '{3}' }}); }}, 1);",
                placeholder.ClientID, getMyWorkspace(), GetParentField(), ID, GetParentField() == "AccountId" ? "AttendeeHistory eq null or AttendeeHistory eq false" : "1 eq 1");

In this example we are checking to see what the GetParentField() function returns.  This function returns the key field used to filter.  In this case I only wanted to add a filter if we are on the Account screen (returns AccountId).  If it does we are adding an additional filter to look for a property called AttendeeHistory and only return null or false values. If not on the account screen, we are adding just a simple 1=1 statement to essentially not filter.

Adding a filter this way ensures it is globally applied even if the user chooses other filter options in the UI.


Viewing all articles
Browse latest Browse all 981