Adding a mobile (cell) phone into the TopContent

2 minute read time.

In the screen shot below you can see that I am looking at a Company Summary screen. A company has a default contact and in my system I have customized the TopContent area to display the phones numbers of the default contact.

The office phone and mobile numbers are displayed while I am in the Company context, to whatever area I move as we can see below.

I was able to add this information by editing the CompanyTopContent screen.

You can see below I entered the Administration area, then within the Company entity area I found the screens.

Editing the screen is easy. Most fields we want to display are included in the underlying view that creates the screen. So it is just a matter of selecting the fields we want. For example the main phone number and the persons full name are easy to include.

But you can see that the mobile (cellular) number is not listed. This is because the view does not include that field.

We can still include the data but we need to use a little trick to allow us to fetch the data we need.

I created a field called 'Dummy' in the Company table. This field is not going to hold any data, but it will give us access to the properties of the field and we can use those to display the data we want.

Here you can see where I have created the Dummy field.

I can now include the dummy field in my CompanyTopContent screen and change its properties so that the mobile (Cellular) phone of the default contact is fetched back.

I used CreateScript to attach code that queries the database and then causes the data to be displayed.

var strSQLStatement = "SELECT RTRIM(ISNULL(dbo.Phone.Phon_CountryCode, '')) + ' ' + RTRIM(ISNULL(dbo.Phone.Phon_AreaCode, '')) + ' ' + RTRIM(ISNULL(dbo.Phone.Phon_Number, '')) AS Phon_FullNumber FROM dbo.Phone INNER JOIN dbo.PhoneLink ON dbo.Phone.Phon_PhoneId = dbo.PhoneLink.PLink_PhoneId INNER JOIN dbo.Company INNER JOIN dbo.Person ON dbo.Company.Comp_PrimaryPersonId = dbo.Person.Pers_PersonId ON dbo.PhoneLink.PLink_RecordID = dbo.Person.Pers_PersonId WHERE (dbo.PhoneLink.PLink_EntityID = 13) AND (dbo.PhoneLink.PLink_Type = N'Mobile') AND dbo.Company.Comp_CompanyId = " + CRM.GetContextInfo("company","comp_companyid")
var myQuery = CRM.CreateQueryObj(strSQLStatement,"");
myQuery.SelectSQL();
if (!myQuery.eof)
{
caption = CRM.GetTrans("OutlookPlugin","phon_numbermobile") +": </span><td>"+myQuery.FieldValue("Phon_FullNumber")+"</td>";
}
else
{
caption = CRM.GetTrans("OutlookPlugin","phon_numbermobile") +": </span><td> </td>";
}

I used here a QueryObject. The SQL joins the current company in context to the default person and through them to their mobile telephone number. If they have a mobile number this is written to the screen using the caption property. The actually caption written to the screen is built from a translation, the returned data and some additional HTML that will format the information correctly.