A customer had a requirement for a summary screen for a custom entity to provide a new company and new person button similar to the core system entities within Sage CRM.
I have assumed that the custom entity pages have been built using the classic ASP pages rather than the .NET API. The example I am using is a new entity called 'Project' which was added using the Advanced Customization Wizard. The technique used here could be easily adapted for the .NET API.
Consider this standard opportunity summary screen.
You can see the New Company and New Person buttons available when the screen is in edit mode.
In contrast you can see below that the default screen for a new custom entity (in this case Project) lacks the buttons.
I have solved by using a mix of the old 'dummy field' trick and by adding some more code into the ASP page.
The Dummy Field
Here you can see I have added a new field called 'Dummy' to the project entity.
The field will not hold data but I can use the field as a very easy way of positioning the material on the screen.
The next thing that I did was to add the following code into the ASP page for the custom entity.
[code language="javascript"]
personPopUp=CRM.Url(Act=1231)+"&JumpReturnCol=proj_personid&JumpIdField=Pers_PersonId&JumpNameField=Pers_FullName&SearchEntity=Person&SearchTable=vSearchListPerson&SearchSql=&searchsqld=&SsDef=20&LinkedField=&Restrictor=Pers_AccountId&RF=&TiedField=proj_personid&SearchText=&PopupWin=Y&RestrictorValue=&RestrictorTEXT="
companyPopUp=CRM.Url(Act=1230)+"&JumpReturnCol=proj_companyid&JumpIdField=Comp_CompanyId&JumpNameField=Comp_Name&SearchEntity=Company&SearchTable=Company&SearchSql=&searchsqld=&SsDef=20&LinkedField=&TiedField=proj_companyid&SearchText=&PopupWin=Y"
newcompanybutton = '<br><table><A HREF="#" class="SmallButtonItem" ONCLICK="';
newcompanybutton += "window.open('" + companyPopUp + "','WebPickerNew','scrollbars=yes,resizable= yes,width=700,height=550');";
newcompanybutton += '">'+CRM.GetTrans("CTICallScreen","newcompany")+'</A></table><br>';
newpersonbutton = '<table><A HREF="#" class="SmallButtonItem" ONCLICK="';
newpersonbutton += "window.open('" + personPopUp + "','WebPickerNew','scrollbars=yes,resizable= yes,width=700,height=550');";
newpersonbutton += '">'+CRM.GetTrans("CTICallScreen","newperson")+'</A></table>';
if(CRM.Mode==Edit)
{
var myEntryBlock = Entry.AddEntry("proj_dummy",2,false);
myEntryBlock.ReadOnly = true;
myEntryBlock.Caption = newcompanybutton + newpersonbutton;
}
[/code]
The code included into the page (for my Project entity this is called 'ProjectSummary.asp') has added the Dummy field to the screen and positioned it.
I have used the property of the field to add the HTML that would create the two hyperlinks to call the new company and person popups.
I also made sure that the field was ReadOnly and appeared only when the screen was in edit mode.
if(CRM.Mode==Edit)
{
var myEntryBlock = Entry.AddEntry("proj_dummy",2,false);
myEntryBlock.ReadOnly = true;
myEntryBlock.Caption = newcompanybutton + newpersonbutton;
}
Another important thing to note are the URL paths and variables. For the new company and new person popup I have used particular system actions and set some variables in the URL.
- JumpReturnCol=proj_companyid (the field that will hold foreign key)
- JumpIdField=Comp_CompanyId (the unique ID field of the new company)
- JumpNameField=Comp_Name (the display field used)
- SearchEntity=Company (the entity searched)
- SearchTable=Company (the table or view used in the search).
The new buttons work like the standard new company and new person buttons