Sage CRM 2020: The display of a photo or image in the person screen

The idea behind this article is that you can use the normal document upload to upload a picture file into the library. That image can then be displayed on the person summary screen.

You will have to change options on the libr_type top allow files of type 'image' to be uploaded.

I have assumed that 1 picture only is stored for an individual.

The Image url will consist of the path associated with person in person record and library directory path. We are going to use action code 1282 which is the system action for View Document within the standard library/document behaviour.

I have used the old trick of creating a dummy field and using the fields caption property to display the image.

The code is a create script to allow the image to be displayed.
if (Values('act')!=1200&&Values('act')!=1201&&Values('act')!=1202&&Values('act')!=141&&Values('act')!=221)
{
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];
}
}
var myRecordId = CRM.GetContextInfo('person','pers_personid');
var myRecord = CRM.FindRecord('library',"libr_type='Image' and libr_personid ="+myRecordId);
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;
}


Please note that this is not a fully worked solution, and that you will need to do extra work but it demonstrates the concept.

As another approach you may want to think about is using clientside code to retrieve the image and to display it into screen.
Anonymous