As requested, this is the PeopleCode behind placing images in BI Publisher Reports Episode
Print Button Component Field Change PeopleCode
/*********************************************************/
/** PeoopleTools Tech Tips **/
/** Randy Groncki 2021-10-15 **/
/** peopletoolstechtips@gmail.com **/
/** BI Publisher **/
/** Send images to BI Publisher Reporrt **/
/*********************************************************/
import PSXP_XMLGEN:*;
import PSXP_RPTDEFNMANAGER:*;
import X_PT3_TEAM_BI_PUB_PRINT:X_Print_Team_List_With_Photo;
Local PSXP_RPTDEFNMANAGER:ReportDefn &oXML_PUB;
Local PSXP_XMLGEN:RowSetDS &oXML_GENERATOR;
Local File &oXML_File;
Local Rowset &RS_Team_List;
Local string &RptDefnID, &XML_Filename_path, &Str_Filename;
Local string &my_xml;
Local integer &i;
/* set report def for later reference */
&RptDefnID = "X_MY_TEAM";
Local X_PT3_TEAM_BI_PUB_PRINT:X_Print_Team_List_With_Photo &LoadTestData = create X_PT3_TEAM_BI_PUB_PRINT:X_Print_Team_List_With_Photo();
&RS_Team_List = &LoadTestData.LoadTeam(%UserId);
/* output files */
rem create sample xml file;
&oXML_GENERATOR = create PSXP_XMLGEN:RowSetDS();
&my_xml = &oXML_GENERATOR.getXMLData(&RS_Team_List, "");
&Str_Filename = "Team_Listing_" | %UserId | ".xml";
&oXML_File = GetFile(&Str_Filename, "W", "UTF8");
&oXML_File.WriteLine(&my_xml);
/* save file name and path for publishing */
&XML_Filename_path = &oXML_File.Name;
&oXML_File.Close();
CommitWork();
/* xml pop */
&Returncode = PutAttachment("record://X_FILEATTACH", &Str_Filename, &XML_Filename_path);
&retcode = ViewAttachment("record://X_FILEATTACH", &Str_Filename, &Str_Filename);
/* Create the report */
/* create report definition */
&oXML_PUB = create PSXP_RPTDEFNMANAGER:ReportDefn(&RptDefnID);
&oXML_PUB.Get();
/* tell the report where to find the xml file data source */
&oXML_PUB.SetRuntimeDataXMLFile(&XML_Filename_path);
/* Process Report */
&oXML_PUB.ProcessReport("", "", %Date, "");
/* save to clear think time functions */
DoSaveNow();
/* publish report to new window */
&oXML_PUB.DisplayOutput();
App Package PeopleCode – Create XML File Data
/*********************************************************/
/** PeoopleTools Tech Tips **/
/** Randy Groncki 2021-10-15 **/
/** peopletoolstechtips@gmail.com **/
/** BI Publisher **/
/** Send images to BI Publisher Reporrt **/
/*********************************************************/
class X_Print_Team_List_With_Photo
method LoadTeam(&In_Oprid As string) Returns Rowset;
private
method LoadEmployeeImage(&Emplid As string) Returns string;
method LoadDummyImage() Returns string;
end-class;
method LoadTeam
/+ &In_Oprid as String +/
/+ Returns Rowset +/
Local Rowset &RS_X_PT3_TEAM_SRCH, &RS_X_PT3_TEAM_VW;
Local integer &i, &j;
/* create rowsets */
&RS_X_PT3_TEAM_VW = CreateRowset(Record.X_PT3_TEAM_VW); /* child rowset */
&RS_X_PT3_TEAM_SRCH = CreateRowset(Record.X_PT3_TEAM_SRCH, &RS_X_PT3_TEAM_VW); /* parent rowset */
/* Fill Parent */
&RS_X_PT3_TEAM_SRCH.Fill("where oprid = :1", &In_Oprid);
/* Loop through parent rowset for processing on each row */
For &i = 1 To &RS_X_PT3_TEAM_SRCH.ActiveRowCount
/* get the user photo */
&RS_X_PT3_TEAM_SRCH(&i).X_PT3_TEAM_SRCH.X_EMPLOYEE_PHOTO.Value = %This.LoadEmployeeImage(&RS_X_PT3_TEAM_SRCH(&i).X_PT3_TEAM_SRCH.EMPLID.Value);
/* Fill child rowset */
&RS_X_PT3_TEAM_VW = &RS_X_PT3_TEAM_SRCH(&i).GetRowset(Scroll.X_PT3_TEAM_VW);
&RS_X_PT3_TEAM_VW.Fill("where oprid =:1", &RS_X_PT3_TEAM_SRCH(&i).X_PT3_TEAM_SRCH.OPRID.Value);
For &j = 1 To &RS_X_PT3_TEAM_VW.ActiveRowCount
/* get employee image */
&RS_X_PT3_TEAM_VW(&j).X_PT3_TEAM_VW.X_EMPLOYEE_PHOTO.Value = %This.LoadEmployeeImage(&RS_X_PT3_TEAM_VW(&j).X_PT3_TEAM_VW.EMPLID.Value);
End-For;
End-For;
Return &RS_X_PT3_TEAM_SRCH;
end-method;
method LoadEmployeeImage
/+ &Emplid as String +/
/+ Returns String +/
Local File &Image_File;
Local string &Base64String, &NewFileName, &FQ_Filename_path;
Local integer &retcode;
&NewFileName = %UserId | %Datetime | ".jpg";
&Image_File = GetFile(&NewFileName, "W");
&FQ_Filename_path = &Image_File.Name;
&Image_File.Close();
rem MessageBox(0, "", 0, 0, "Emplid: %1 Path: %2", &Emplid, &FQ_Filename_path);
&retcode = GetAttachment("record://X_EPHOTO_VW", &Emplid, &FQ_Filename_path);
rem MessageBox(0, "", 0, 0, "result: %1", &retcode);
If &retcode < 2 Then
&Image_File = GetFile(&FQ_Filename_path, "R", %FilePath_Absolute);
&Base64String = &Image_File.GetBase64StringFromBinary();
&Image_File.Close();
End-If;
/* delete file */
&Image_File = GetFile(&FQ_Filename_path, "R", %FilePath_Absolute);
&Image_File.Delete();
<* this makes the xml file unnecessarily large with a repeated default image
If None(&Base64String) Then
&Base64String = %This.LoadDummyImage();
End-If; *>
Return &Base64String;
end-method;
method LoadDummyImage
/+ Returns String +/
Local File &Image_File;
Local string &Base64String, &NewFileName, &FQ_Filename_path;
Local integer &retcode;
&NewFileName = %UserId | %Datetime | ".jpg";
&Image_File = GetFile(&NewFileName, "W");
&FQ_Filename_path = &Image_File.Name;
&Image_File.Close();
&retcode = GetAttachment("record://X_DESIGN_IMG_VW", "PT_DUMMY_PHOTO110", &FQ_Filename_path);
If &retcode < 2 Then
&Image_File = GetFile(&FQ_Filename_path, "R", %FilePath_Absolute);
&Base64String = &Image_File.GetBase64StringFromBinary();
&Image_File.Close();
End-If;
/* delete file */
&Image_File = GetFile(&FQ_Filename_path, "R", %FilePath_Absolute);
&Image_File.Delete();
Return &Base64String;
end-method;