CRM.AddContent() & Dummy Field Trick

1 minute read time.

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 tag so is not a suitable technique for adding additional fields. But it is very useful for injecting HTML and Jscript into browser.

Parents
  • 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

Comment
  • 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

Children
No Data