Creating a PipeLineGraphic in an application extension using COM API ASP

Less than one minute read time.
I have discussed in a previous article how customization can be carried out on a PipeLineGraphic chart used in a system built page, for example on the Opportunity List page in the My CRM tab area.

The PipeLineGraphic block is available within the COM and .NET APIs but it has not always been straight forward to know how to use it. So hopefully this little snippet of code will help.


// declare variables
var strSQL="", Chart, queryObj, strStage="", strParam="", strChart, strhref="";
var iUserId = CRM.GetContextInfo("user","user_userid")'
Chart = CRM.GetBlock("pipeline");
with (Chart)
{
PipelineStyle('SelectedWidth','1');
PipelineStyle('SelectedHeight','10');
PipelineStyle('PipeWidth','40');
PipelineStyle('PipeHeight','60');
PipelineStyle('Margin','80');
PipelineStyle('ShowLegend','False');
}
strhref="reports/opposbystage.asp?stage=";
strSQL = "select oppo_stage, count(*) as t from vopportunity with (nolock) where oppo_status='In Progress' and oppo_assigneduserid="+iUserId+" group by oppo_stage";
queryObj = CRM.CreateQueryObj(strSQL);
queryObj.SelectSQL();

while(!queryObj.eof)
{
if(queryObj("t")!="0")
{
strStage = CRM.GetTrans("oppo_stage",queryObj("oppo_stage"));
Chart.AddPipeEntry(strStage,queryObj("t"),queryObj("t")+" "+strStage,"Javascript:ShowReport('"+queryObj("oppo_stage")+"')");
}
queryObj.Next();
}

Response.Write(Chart.Execute();