Adding a new Panel to a Summary screen e.g. Company Summary

A screen like the company summary screen has a very particular structure because it is partially defined in meta data and partial has its structure hard coded into the system action being called. The detail of this is discussed in the article "Changing a Summary Screen (e.g. Company Summary Screen)".

But imagine the business case where you have added new fields to the company table

  • comp_creditcheckdate
  • comp_creditrating
  • comp_creditcheckagency
  • comp_creditcheckmaximum

Of course these new fields can be added to the existing screen block that is defined in meta data which is "companyboxlong", but if we want to display these fields in a seperate panel then we will run into the issue that normally we can not control the blocks used in a default system action like 'companysummary'.

The basic strategy that I have used here is to define the extra block in meta data and then take advantage of the Caption property of a field and use that property to add the HTML into the screen. A script in the custom content box can then be used to position the panel.

My business requirement is that the extra panel should only display on the main Summary Page and not display when the company screen is in Edit Mode.

Step 1:

Add the fields.

I have added the fields listed above. And I have also added a dummy field "comp_dummy". The use of a Dummy field is quite a common trick for example it is used in this article "How do I put calculated or derived info in a screen's top content?"

Make sure the field level security is set so that the comp_dummy field is read only.

Step 2:

Create the basic screen. Mine was called "CreditCheck". See the last image of this article.

Step 3:

Create the block. I called mine creditcheckblock and it needs to be an entrygroup. We need to do this so that the panel inherits the label and borders.

Step 4:

Add the code to create script of the Dummy field.

if (Values("Act") == 200 || Values("Act") == 520 || Values("_actionid") == 201) {
var intRecordId = CRM.GetContextInfo("company", "comp_companyid");
var CreditCheckPanel = CRM.GetBlock("CompanyCreditCheckBoxBlock");
CreditCheckPanel.DisplayButton("1") = false;
CreditCheckPanel.DisplayForm = false;
var myRecord = CRM.FindRecord("company", "comp_companyid=" + intRecordId);
var strBlockHTML = CreditCheckPanel.Execute(myRecord);
Caption = "<script" + ">";
Caption += "var strPanelHTML ='";
Caption += strBlockHTML;
Caption += "';";
Caption += "<" + "/script>"
}
else {
Hidden = true;
}

This code makes sure the panel is only added when the company summary screen is in view mode.

The HTML for the panel is contained in the variable strBlockHTML which is going to be passed to the browser and used in the next step.

Step 5.

The following code needs to be added to the custom content of the companyboxlong screen.

<script>
crm.ready(function () {
if (crm("comp_name").getMode()=="view")
{
var myRowGaps = $("TD.ROWGap");
myRowGaps[0].innerHTML += strPanelHTML;
}
})
</script>

The code above is a combination of Client Side API and jQuery. The code checks that the code is in View Mode. It then looks for the first occurrence of a table cell with the cascading style sheet class of "RowGap". It then adds the HTML for the panel contained in the variable strPanelHTML; this was the variable that was passed into the browser from the code added to the Caption property of the Dummy field's create script.

Note:

In this example the additional fields that are displayed in the extra panel are edited using a screen called from a tab option.

Anonymous
  • The way in which Summary Screens are created for default entities (Company, Person etc) has not changed as of Sage CRM 2019 R2.

  • Anyone know if there is an update or change since new versions have been released about adding panels to summary screens? It seems like a lot of work to create a whole need .net page just so the users can edit.

  • Penny

    I don't think that this would be a bug. We are trying to do something here that is not really in the APIs. We are inserting code into a system page. If there is a problem with certain types of fields being displayed this way then we probably need to think about changing the HTML inserted.

  • Hi Jeff,

    I have an issue that occurs with this code when I add an email field into the screen that is being called by the entrygroupblock.

    It appears to dislike the syntax of the mailto script that is associated with the email field type and breaks the script with the message:

    "Uncaught SyntaxError: Unexpected string"

    I have attempted other ways of inserting the screen to replace the original screen (which is what I require) but it breaks with this one field type. Otherwise, I don't have an issue.

    Here is the part of the script that appears for troubleshooting:

    "Site Contact Email:

    ' "

    Is this a bug I should report to Sage Support?

    Thanks Jeff.

    Regards,

    Penny

  • Jeff:

    Thank you! It is good to know that I could use ASP to redo the edit page for the Oppo. However, I think I am going to make it easier on myself and add the modification of the additional panel to workflow. If the user hits the change button on the summary page, the panel will not display. If the data on the panel needs to be updated, it will be handled in workflow.

    Fingers crossed that works out for me!

    I greatly appreciate your assistance with my questions! Thank you!