Steps to add a pipeline to show Opportunities for a Company

You can graphically represent data over a chosen cross section by using a pipeline graphic. To add a pipeline graphic, you need to use methods exposed by the CRMPipelineGraphicBlock object.

When a user clicks a section of the pipeline graphic, the corresponding list is filtered to show entries related to that section. You can automatically display a pipeline graphic in the Opportunities, Cases, and Leads list screens in the context of My CRM, Company, People, Opportunity, Case, and Lead.

The example below displays the forecasted value of various stages of opportunities for a Company. Within the ASP, you must pass the pipeline the user's context and a field to uniquely identify the current company.

Step 1: Create a custom ASP file

Add the following code to the file:

  1. Get the ID of the current Company and store it in a variable:
    Copy
    var CompId=CRM.GetContextInfo('company','comp_companyid');
  2. Retrieve details about the opportunities from the Sage CRM database and store them in a variable as a string:
    Copy
    var SQLPipe='select sum(Oppo_Forecast) as a,' +'Oppo_Stage from vOpportunity ' +'where (Oppo_PrimaryCompanyid='+CompId+') ' +'group by Oppo_Stage order by Oppo_Stage';
  3. Convert the string stored in the SQLPipe variable into an object, store that object in another variable, and then execute the stored object:
    Copy
    var Querypipe=CRM.CreateQueryObj(SQLPipe);
    Querypipe.SelectSQL();
  4. Get the pipeline block and store it in a variable.
    Copy
    var pipe=CRM.GetBlock('pipeline');
  5. Add pipeline entries and display the pipeline on the screen.
    For example:
    Copy
    while (!Querypipe.EOF)
    {
        Label=Querypipe('Oppo_Stage');
        Value=Querypipe('a');
        pipe.AddPipeEntry(Label,parseFloat(Value),Value+"");
        Querypipe.Next();
    }

    pipe.Selected=2;
        
    // The summary allows the addition of any desired text in HTML format for the selected pipe section.
    // This example shows a simple hard coded value.
    pipe.Pipe_Summary='<Table><td class=TableHead>Qualified(70)</td></table>';
    CRM.AddContent(pipe.Execute());
    Response.Write(CRM.GetPage());

    For the complete ASP page code sample, see Code sample: Adding a pipeline.

  6. Save your ASP file to the CustomPages folder in the Sage CRM installation directory.
    The default location of the CustomPages folder is %ProgramFiles(x86)%\Sage\CRM\CRM\WWWRoot

Step 2: Add a new tab and link it to your ASP file

  1. In Sage CRM, go to <My Profile> | Administration | Customization.
  2. Click Company, and then click Tabs.
  3. In the Tab Group Name column, click Company.
  4. Under Properties, use the following options:
  5. Click Update, and then click Save.