Login / Register  search  syndication  about

          Jason Buss' Blog

Jason Buss on SalesLogix development & customization, SQL, and more.

Adding items to the Opportunity Snapshot (LAN)

The opportunity snapshot on the Opportunity Detail view is a handy place to display summary information, but customizing it can be a bit confusing.  The Snapshot is simply a browser control, displaying HTML which is being generated by a method on the Opportunity detail screen.  You can see the HTML code in that method (LoadSnapShot), but it is so broken up and pieced back togther to add variable data, that it can be a little tough to navigate.  Hopefully this basic rundown helps explain how the snapshot is put together, and how simple it can be to add new information.

First, let's take a look at the conditions involved in generating the snapshot (Opportunity Detail view, LoadSnapshot method).  Primarily, the Opportunity status is checked  to determine which version of the snapshot is to be displayed.  I've cleared out the html in this code, so we can see how things are setup based on status.

The first thing checked is to see if the current status is either Open or Inactive (I've cleared out localization code as well to make this more readable):

If strStatus = "Open" Or pklStatus.Text = "Inactive" Then

In this area, they set up the header information for the HTML           
    If Not blnMCEnabled Then
Here they display pricing information, depending if Multi Currency is enabled or not.           
    End If

Finally, they show summary information for the opportunity which is not reliant on currency.  This is usually fields like Days Open, Current Stage, etc...  This is repeated for both Closed statuses as well as a catch all for any other status value.

ElseIf strStatus = "Closed - Won" Then
'Header Info
    If Not blnMCEnabled Then
'MultiCurrentcy enabled
'MultiCurrentcy disabled
    End If
'Summary Information
ElseIf strStatus = "Closed - Lost" Then
    If Not blnMCEnabled Then
    End If
Else 'The code below is a "default" if the user addes a picklist value that doesn't equal the above conditions out of box.
    If Not blnMCEnabled Then
    End If
End If

That's all there is to the code in terms of WHERE you want to edit, but there is a lot of broken up HTML to navigate at that point; However, If you search for label values in the Snapshot code, and do a little copying/pasting, it's not do difficult to add some additional information to this area.

I'm going to add a "Total Margin" field in the Value section of the snapshot.  Total Margin will be defined as (TotalSales - TotalFixedCost) / TotalSales.  We'll want to calculate margin based off of both SalesPotential for Open Opportunities, and ActualAmount for Closed Opportunities.

First of all, we need to get the total cost value.  I'm going to add this code near the top of the LoadSnapShot method on Opportunity Detail.  This will give me a variable name dTotalCost containing the total cost value for all products on the current opportunity:

    Dim dTotalCost

    Set objCostRS = objSLXDB.GetNewRecordSet
    strSql = "select sum(p.fixedcost) as totalcost from opportunity_product o inner join product p on o.productid = p.productid" & _
             "Where o.opportunityid = '" & strCrntOppID & "'")
    objCostRS.Open strSql, objSLXDB.Connection

    If  objCostRS.RecordCount <> 0 Then
        dTotalCost = objCostRS.Fields("totalcost")
        dTotalCost = 0
    End If

    Set objCostRS = Nothing

Now that we have cost, we have to calculate the margin.  I do this in two places actually.  First right outside the first If statement that checks the opp status, and I also set it inside the If statement if status is "Open".  I do this because margin will be based off of the Actual Close Amount if the Opp has any closed status, and off of Sales Potential if the status is Open or Inactive.

(My added code is in bold, you will probably find this right around line 370 on the Opp detail form code)

            If IsNull(objRS.Fields("WSALE").Value) Then  'DNL
               lngWeighted = 0
               lngWeighted = objRS.Fields("WSALE").Value  'DNL
            End If

            If cDbl(intActualAmount) = 0 Then
                dMargin = 0
                dMargin = (cDbl(intActualAmount) - cDbl(dTotalCost)) / cDbl(intActualAmount)
            End If

            Application.BasicFunctions.GlobalInfoSet "CurrentStatus", strStatus  'DNL
            If Application.Translator.Localize(strStatus) = Application.Translator.Localize("Open") Or Application.Translator.Localize(pklStatus.Text) = Application.Translator.Localize("Inactive") Then  'DNL

               If lngSalesPotential = 0 Then
                    dMargin = 0
                    dMargin = (cDbl(lngSalesPotential) - cDbl(dTotalCost)) / cDbl(lngSalesPotential)
               End If

Now that we've calculated the Margin value, we need to insert it into the snapshot.  Because of how the snapshot is being built, we'll need to add it in eight different places, twice for each Opportunity Status (Open or Inactive, Closed Won, Closed Lost, other).  If you know that multicurrency functionality is not an important aspect of your database, you can add it only once for each status).

                  vHTML = vHTML + "<td class=indent>" & Application.Translator.Localize("Sales Potential = ") & FormatCurrency(lngSalesPotential, 2)
                  vHTML = vHTML + "</tr><tr>"
                  vHTML = vHTML + "<td class=indent>" & Application.Translator.Localize("Weighted = ") & FormatCurrency(lngWeighted, 2) 'Calculated Field
                  vHTML = vHTML + "</tr><tr>"

You can justcopy the last two lines here, and change the copied line to use our new margin values to add it to the snapshot.

                  vHTML = vHTML + "<td class=indent>" & Application.Translator.Localize("Margin = ") & FormatCurrency(dMargin, 2) 'Calculated Field
                  vHTML = vHTML + "</tr><tr>"

You'll then want to go through the code and add this new line in each of the MultiCurrency sections for each status.  

Adding a single new value is simple enough, but if you try to get more complicated with it, keep a close eye on <td> and <tr> tags before and after any code you enter to avoid breaking the Snapshot all together.


I hope this post is helpful in explaining the basics of how the snapshot is put together, and encourages people to experiment with modifications to this area.  Thanks for reading!  Smile



What's This?
Bookmark and Share

About Jason Buss

   Jason is a senior application developer with Customer FX.

Related Content
   Can I Bind an Attachment to a Specific Activity in Infor CRM version 7.54?
Recently I had a user ask if they could bind an attachment to a specific Activity within Infor CRM??
Posted on Jul 07, 2015 by Dale Richter to Infor CRM Questions & Answers
   Infor CRM (formerly SalesLogix) Administrator Locked Out
I thought I had seen all the issues affecting the datalink but this was a new one. We could not login t
Posted on Jun 18, 2015 by Mark Duthoy to SalesLogix Support
   How do I remove users from my Infor CRM system (formerly SalesLogix)?
I had an Administrator ask me for the steps they needed to take in order to remove a user from the Infor
Posted on May 08, 2015 by Dale Richter to Infor CRM Questions & Answers
   Infor CRM (Formerly Saleslogix) v8.1 update 03 and 05- Uncaught Error Scheduling Contact Processes
 In the Infor CRM (formerly Saleslogix) web client, under the Contact area you have the ability to s
Posted on May 07, 2015 by Kris Halsrud to Kris Halsrud's Blog
   Using Global Script functions in InforCRM
I recently had a project that required me to be able to check if a user belonged to a particular team.
Posted on May 05, 2015 by Jason Buss to Jason Buss' Blog

No Comments

Leave a Comment

All contents Copyright © 2015 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register