Sage CRM 2020: Displaying an Image on a Custom Entity Page

I have assumed that you have created the new entity using the Advanced Customization Wizard. Since Sage CRM 2020 R2 the licensing model has been changed to allow all partners and customers to be able to use the wizard.  You can download the latest version of the wizard here: https://community.sagecrm.com/partner_community/m/sage_crm_downloads/default.aspx.

I have also assumed that when the entity was created the option to include child documents was selected.

Our custom entity therefore has the ability to upload images to its 'library'.

I then made sure there was a option for 'Image' in the libr_type field, this is to allow me to indicate that the uploaded file is an image. I then added a dummy field into the project table e.g. proj_projectimage. I made the field readonly using the Field Level S ecurity. I included in the field in the default project summary screen - ProjectNewEntry.

Then I added the code to the create script of the 'dummy' field.

var strJump = Values("J");
re = /projectnew/i; 
r = strJump.search(re) 
if (r==-1)
{
var SID
var strPath = CRM.URL(220);
//the system action 220 is for the person summary screen
var arrayFullKeys = strPath.split("?");
//arrayFullKeys[0] contains path up like "/crm/CRM.dll/Do"
var arrayKeys = arrayFullKeys[1].split("&");
for (var i=0;i<arrayKeys.length;i++)
{
var arrayValue = arrayKeys[i].split("=");
if (arrayValue[0].toLowerCase()== "sid")
{
SID = arrayValue[1];
}
}
//This is used in pages which are linked to from list custom jump.

var intRecordId = Values("proj_projectid");
var myRecord = CRM.FindRecord('library',"libr_type='Image' and libr_projectid ="+intRecordId);
var pictureURL = arrayFullKeys[0]+"/";
if (!myRecord.eof)
{
//pictureURL += custom_sysparams.parm_value;
pictureURL += myRecord.Libr_FilePath;
pictureURL += myRecord.Libr_FileName;
pictureURL += "?SID=";
pictureURL += SID;
pictureURL += "&Act=1282&Mode=0&FileName=";
pictureURL += myRecord.Libr_FilePath;
pictureURL += myRecord.Libr_FileName;
Caption = "<img border=1 width=80 src='"+pictureURL+"'>";
}
else
{
Caption = "No Image Available";
}
}
else
{
Hidden = true;
}

Note: Because of my earlier assumption that the code for the ASP pages was generated by the Advanced Customization Wizard I can use the fact that the summary page is called projectsummary.asp and the entry page is projectnew.asp. This makes it very easy for me to determine whether I am in looking at an existing record or whether I am in the process of creating one.

To change this for your own entities you will need to look through the code and see where I have referenced the project entity. Just change those references for your own and all should be well.

Anonymous