Changing the Sort in the SalesLogix 7.5.2 Web Client What’s New

The SalesLogix web client offers a What’s New  navigation item that allows a user to see new and updated items:

SalesLogix Web Whats New

 

If you look in the Application Architect at the Pages under the SalesLogix Web Client you can see there is a page for What’s New:

SalesLogix Application Architect Whats new Page

 

Notice that the Page does not contain smart parts matching up with the tabs you see from the SalesLogix web client.  Take a look on the Modules tab of the Whats New Page…

 

 

SalesLogix Application Architect Whats new Page - Modules

 

OK, so here we can see that a module is employed.  The module is in the assembly Sage.SalesLogix.Web.Modules, and is called WhatsNewModule.

You can and should take a look at the module at some point to see what it is doing, using something like Reflector. I will skip over doing that here but basically the module loads onto the What’s New Page, several custom smart parts.  Where are those smart parts?  Well take a look in the Support Files under the Portal in the Application Architect.  Expand out the Project Explorer and under Sage SalesLogix…Support Files…Smart Parts…What’s New you will see all of the various custom smart parts:

SalesLogix Application Architect Whats New Smart Parts

 Each smart part matches to a tab in the What’s New Area. For instance, AccountsWhatsNew.aspx and aspx.cs are the control and code file for the Account tab.

 Now to the point of this article.  The Whats new feature is nice but if you have used it in the past you might have noticed the sort is not from most recent to oldest, as one might expect.  So lets take a look at what we need to do to change that. 

 

First of all, we will not need to worry about changing any of the ascx pages.  All of the stuff we care about is in the cs code files.  I will go ahead and show you how to manipulate the Account page.  From there it should be easy to do similar steps for the other tabs.

Lets open up the AccountsWhatsNew.ascx.cs file.  Double click that file in the project explorer in the Application Architect (under Sage SalesLogix…Support Files…Smart Parts…What’s New ).’

SalesLogix Application Architect Account Whats New code file 

There are a couple of spots in the code we will want to change.  All of the code is found in the OnPreRender event.

I will include the original code here:

protected override void OnPreRender(EventArgs e)
{
    if (!Visible) return;

    DateTime fromDate = DateTime.UtcNow;
    IUserOptionsService userOptions = ApplicationContext.Current.Services.Get<IUserOptionsService>();
    if (userOptions != null)
    {
        try
        {
            fromDate = DateTime.Parse(userOptions.GetCommonOption(“LastWebUpdate”, “Web”, false, fromDate.ToString(), “LastWebUpdate”));
        }
        catch
        { }
    }

    SearchOptions.SearchDate = fromDate;
    //New Accounts
    SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.New;
    if (!String.IsNullOrEmpty(grdNewAccounts.SortExpression))
    {
        SearchOptions.OrderBy = grdNewAccounts.SortExpression;
        SearchOptions.SortDirection =
            (grdNewAccounts.CurrentSortDirection.Equals(“Ascending”, StringComparison.CurrentCultureIgnoreCase))
                ? ListSortDirection.Ascending
                : ListSortDirection.Descending;
    }
    WNRequest.SearchOptions = SearchOptions;
    grdNewAccounts.DataSource = AccountsNewObjectDataSource;
    grdNewAccounts.DataBind();

    //Modified Accounts
    SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.Updated;
    if (!String.IsNullOrEmpty(grdModifiedAccounts.SortExpression))
    {
        SearchOptions.OrderBy = grdModifiedAccounts.SortExpression;
        SearchOptions.SortDirection =
            (grdModifiedAccounts.CurrentSortDirection.Equals(“Ascending”, StringComparison.CurrentCultureIgnoreCase))
                ? ListSortDirection.Ascending
                : ListSortDirection.Descending;
    }
    else
    {
        SearchOptions.OrderBy = “ModifyDate”;
        SearchOptions.SortDirection = ListSortDirection.Ascending;
    }
    WNRequest.SearchOptions = SearchOptions;
    grdModifiedAccounts.DataSource = AccountsModifiedObjectDataSource;
    grdModifiedAccounts.DataBind();

    base.OnPreRender(e);
}

And the new code with my changes shown in red here:

protected override void OnPreRender(EventArgs e)
{
    if (!Visible) return;

    DateTime fromDate = DateTime.UtcNow;
    IUserOptionsService userOptions = ApplicationContext.Current.Services.Get<IUserOptionsService>();
    if (userOptions != null)
    {
        try
        {
            fromDate = DateTime.Parse(userOptions.GetCommonOption(“LastWebUpdate”, “Web”, false, fromDate.ToString(), “LastWebUpdate”));
        }
        catch
        { }
    }

    SearchOptions.SearchDate = fromDate;
    //New Accounts
    SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.New;
    if (!String.IsNullOrEmpty(grdNewAccounts.SortExpression))
    {
        SearchOptions.OrderBy = grdNewAccounts.SortExpression;
        SearchOptions.SortDirection =
            (grdNewAccounts.CurrentSortDirection.Equals(“
Ascending“, StringComparison.CurrentCultureIgnoreCase))
                ? ListSortDirection.Ascending
                : ListSortDirection.Descending;
    }
    else
    {
        SearchOptions.OrderBy = “CreateDate”;
        SearchOptions.SortDirection = ListSortDirection.Descending;
    }

    WNRequest.SearchOptions = SearchOptions;
    grdNewAccounts.DataSource = AccountsNewObjectDataSource;
    grdNewAccounts.DataBind();

    //Modified Accounts
    SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.Updated;
    if (!String.IsNullOrEmpty(grdModifiedAccounts.SortExpression))
    {
        SearchOptions.OrderBy = grdModifiedAccounts.SortExpression;
        SearchOptions.SortDirection =
            (grdModifiedAccounts.CurrentSortDirection.Equals(“
Ascending“, StringComparison.CurrentCultureIgnoreCase))
                ? ListSortDirection.Ascending
                : ListSortDirection.Descending;
    }
    else
    {
        SearchOptions.OrderBy = “ModifyDate”;
        SearchOptions.SortDirection = ListSortDirection.Descending;
    }
    WNRequest.SearchOptions = SearchOptions;
    grdModifiedAccounts.DataSource = AccountsModifiedObjectDataSource;
    grdModifiedAccounts.DataBind();

    base.OnPreRender(e);
}

There you have it.  Save your changes and deploy to the web site.  (Since  this is a custom smart part you do not need to re-build first).

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!