CRM.AddContent() & Dummy Field Trick

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

CRM.AddContent() & Dummy Field Trick

  • Comments 6
  • Likes

I thought I had written about this trick before but it appears not!

A customer needed a technique to allow a chart to be displayed at the top of the company screen.  This is a bit like the PipeLineGraphic of the OpportunityList or CaseList system screens.

The way this has been added is really very simple.

First I added a dummy field into the screen.  The Dummy field is an old trick and it provides a way of injecting new HTML into the screen.

To add the dummy field, I went to

Administration -> Customization -> Company 

Within the fields tab, I clicked 'new' and added a new field. I called mine comp_dummy and save it as a text field with a length of 1.  I then set the field to be readOnly using Field Level Security. 

After I had created the field, I edited the companyboxlong screen. 

I added the comp_dummy field into the screen and then updated the Dummy field's create script:


Caption = " ";
if(Values("Act")==200||Values("Act")==520||Values("_actionid")==201)
{
var intRecordId = CRM.GetContextInfo("company","comp_companyid");
var strSQL = "select count(oppo_opportunityid) as 'mycount', 'Opportunities' as 'mytype' from opportunity where oppo_primarycompanyid = "+intRecordId +"union select count(case_caseid) as 'mycount', 'Cases' as 'mytype' from cases where case_primarycompanyid = "+intRecordId+" union select count(cmli_commlinkid) as 'mycount', 'Communications' as 'mytype' from comm_link where cmli_comm_companyid = "+intRecordId;
var myBlock=CRM.GetBlock("chart");
with(myBlock)
{
Stylename("Bar");  
xlprop="mytype";
yprop="mycount"; 
SQLText= strSQL;
ImageWidth=950;
}
CRM.AddContent(myBlock.Execute());
}
  

Note:  I have used CRM.AddContent() which allowed me to add HTML to page body.  It was added immediately before the <Form> tag so is not a suitable technique for adding additional fields.  But it is very useful for injecting HTML and Jscript into browser.

 

Comments
  • Hi Jef,

    This is really very useful for our customization.

    Thanks

    Raja M

  • Hi Jef,

    We had this kind of chart for quite a while now. But it seems with the update to version 7.1 it no longer works.

    We double checked the SQL statement and found it working.

    Also there is a white (transparent) area exactly the size the chart would be at the beginning of the page.

    I have tried it with many different parameters in the with(myblock) field, but nothing seems to work.

    Can anyone confirm it still works with version 7.1 and if so, were any changes made?

    Thanks in advance for any help on this subject.

    L.Stahel

  • This works for me.  I am using Sage CRM v7.1d.  The graph looks different because of the new way it is rendered using the new Fusion chart classes, but it does still work.

  • Thank you Jeff

    I don't know why but it seems to work now..

  • Mhm it have significantly longer loading times whith this chartdemo on my developer machine. Dashboard is 3 times faster loading with empty database then this (with 1 democompany and 2 opportunities). Do someone know why this is such slow?

  • Is that just the drawing of the screen?