Adding a one click history print feature to the SalesLogix web client

One of the things that the SalesLogix LAN client had was the ability to print details about a single history item by selecting the record in the history grid and clicking a print button.

The SalesLogix web client does not have that capability.  But I am going to show you how to implement something similar.

 

The first thing you will need to do is create a Crystal report that is based off the History table as the primary table, i.e. a history detail report.  The standard reports in the system regarding history are not meant to be for a particular history record but instead reports showing all history for a given account, contact, etc.  You do not need to have any parameters on the report to define the History ID to use.  We will handle that in code.

Once you have your report created and added to the system, we can put together the code needed to invoke the report for a given history record.

Our modifications will all involve two files: HistoryList.ascx and HistoryList.ascx.cs.  Both of these files are custom smart parts.  You can find these in the application architect by navigating in the Project Explorer to”Portal Manager…Sage SalesLogix…Support Files…Smart Parts…History. 

 

Lets take a look at the ASCX file first.  In here we are going to do two things.  Change the mark up for the grid to add a couple columns.  Add a custom style to the page, and add a grid event definition.

Changing the markup for the grid:

 

The History grid markup contains the definitions for the columns that appear in the grid.  By default the column definitions of the grid look like this:

    <Columns>
        <asp:TemplateField HeaderText=”<%$ resources: HistoryGrid.Columns.Type.HeaderText %>” SortExpression=”Type”>
           <itemtemplate>
                <asp:HyperLink id=”A1″ runat=”server” Target=”_top”
                    NavigateUrl='<%# GetHistoryLink(Eval(“HistoryId”)) %>’>
                    <img alt='<%# GetToolTip(Eval(“Type”)) %>’ style=’vertical-align:middle;’
                        src='<%# GetImage(Eval(“Type”)) %>’ />&nbsp;<%# GetToolTip(Eval(“Type”)) %>
                </asp:HyperLink>
            </itemtemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText=”<%$ resources: HistoryGrid.Columns.CompleteDate.HeaderText %>” SortExpression=”CompletedDate”>
            <ItemTemplate><%# GetLocalDateTime(Eval(“CompletedDate”), Eval(“Timeless”))%></ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField=”User” HeaderText=”<%$ resources: HistoryGrid.Columns.Leader.HeaderText %>” SortExpression=”User” />
        <asp:BoundField DataField=”ContactName” HeaderText=”<%$ resources: HistoryGrid.Columns.ContactName.HeaderText %>” SortExpression=”ContactName”/>
        <asp:BoundField DataField=”Description” HeaderText=”<%$ resources: HistoryGrid.Columns.Description.HeaderText %>” SortExpression=”Description” />
        <asp:BoundField DataField=”Result” HeaderText=”<%$ resources: HistoryGrid.Columns.Result.HeaderText %>” SortExpression=”Result”/>
        <asp:BoundField DataField=”Notes” HeaderText=”<%$ resources: HistoryGrid.Columns.Notes.HeaderText %>” SortExpression=”Notes”/>
        <asp:BoundField DataField=”Category” HeaderText=”<%$ resources: HistoryGrid.Columns.Category.HeaderText %>” SortExpression=”Category”/>
    </Columns>

 

 

We want to add to additional columns at the very far right of the grid, so we will add our new column definitions after the BoundField column for Category.  The placement of the new columns is not required to be where I am placing them but be aware we do need to know the index position of our fields.  We will be using them in our code behind shortly.  Lets look at our two new fields in markup:

<asp:ButtonField ButtonType=”Link” CommandName=’Print’ Text=”Print”  />       
<asp:BoundField datafield=”HistoryId” Visible=”true”/>   

 The first line in our markup is a new Link button that shows the word “Print”.  The other column is the History ID of the current record.

 

 

Adding the custom style

The next thing we will do to the ASCX file is add some custom styles.  We want to add two particular styles.  One to hide the History ID column we added so the user does not have to see it, and one to add underlining to our “Print” column.  At the top of our ASXC page, immediately after the Register Assembly lines of code, we can add our custom styles, like so:

<style type=”text/css”>
    .hiddencol
    {
        display:none;
    }
    .bluecol
    {
        text-decoration:underline;                     
        color:Blue;
    }
</style>

 

Adding the new grid event

 

 

The final step in the ASCX file is to add a new event to the grid attributes.  These attributes are listed in the markup right before the columns definitions.  The standard attributes look like:

<SalesLogix:SlxGridView ID=”HistoryGrid” runat=”server” AutoGenerateColumns=”False” CellPadding=”4″ EnableViewState=”false” ForeColor=”#333333″
    GridLines=”None” CssClass=”datagrid” AllowPaging=”true” PageSize=”10″ AllowSorting=”true” CurrentSortDirection=”Descending”
    ShowEmptyTable=”true” EmptyTableRowText=”<%$ resources: HistoryGrid.EmptyTableRowText %>” ShowSortIcon=”true”>

 

We are going to add a new event definition for the grid’s OnRowDataBound event and the end of the other attributes, like so:

 

<SalesLogix:SlxGridView ID=”HistoryGrid” runat=”server” AutoGenerateColumns=”False” CellPadding=”4″ EnableViewState=”false” ForeColor=”#333333″
    GridLines=”None” CssClass=”datagrid” AllowPaging=”true” PageSize=”10″ AllowSorting=”true” CurrentSortDirection=”Descending”
    ShowEmptyTable=”true” EmptyTableRowText=”<%$ resources: HistoryGrid.EmptyTableRowText %>” ShowSortIcon=”true” OnRowDataBound=”HistoryGrid_RowDataBound”>

 

Now that we have finished modifiyng the ASCX file, lets go onto modifying the code file, the ASCX.CS.  In this file we are going to add our code for the new grid event we added for the OnRowDataBound event.  This code will do two things, set the custom style attributes of our new columns and add a client side click event for the “Print” column.  Lets see the code:

protected void HistoryGrid_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)

{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Cells[ 8  ].CssClass = “bluecol”;
        e.Row.Cells[9].CssClass = “hiddencol”;
        // Retrieve the state value for the current row.            
        String id = e.Row.Cells[9].Text.ToString();

        LinkButton btn = (LinkButton)e.Row.Cells[ 8   ].Controls[0];
        btn.Attributes.Add(“onclick”, “if (confirm(‘Are you sure you want to print this history record?’)){ShowReport(‘History:History Summary – Sample’,’History’,'” + id + “‘);return false} else {return false}”);
    }
}

A couple of things to note.  We have to refer to the columns by index position they appear in the grid. The index is 0 based.  If your columns are not the 8th and 9th columns you would need to change your code.  Also, the client side code utilizes the SalesLogix “ShowReport” function.  See more about the client side reporting library here.

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) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!