New Company and New Person buttons in a Custom Entity screen.

2 minute read time.

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 = '

'" + companyPopUp + "','WebPickerNew','scrollbars=yes,resizable= yes,width=700,height=550');";
newcompanybutton += '">'+CRM.GetTrans("CTICallScreen","newcompany")+'

';

newpersonbutton = '

'" + personPopUp + "','WebPickerNew','scrollbars=yes,resizable= yes,width=700,height=550');";
newpersonbutton += '">'+CRM.GetTrans("CTICallScreen","newperson")+'
';

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

  • Jeff: I need to add a company "on the fly" while entering a new record in a custom entity. I believe this is what you are demonstrating above.

    However, when I try to apply the above example code to my custom entity asp page, I receive a 505 error. I do understand that I cannot just copy the code and I am "good to go". :-) I did adjust proj_personid and proj_companyid to my custom entity prefix. I also added the following to the asp page..

    var personPopUp;

    var companyPopUp;

    var newcompanybutton;

    var newpersonbutton;

    Along with a semi colon at the end of personPopUp= and companyPopUp

    After going through the code, there is one piece that I am unsure where it is coming from and was hoping you could point me in the right direction to understand it.

    This is the line that I am having an issue with...

    var myEntryBlock = Entry.AddEntry("acq_dummy1",2,false);

    Out of that line, I don't understand where Entry is coming from. Is Entry something that is predefined and CRM knows what that is and what to do with it or is Entry something that was already defined in the page you were working with and I need to define it in my asp page.

    Any assistance you could provide would be greatly appreciated.

    Thank you! Michele