How can i export report result into pdf format (php code) ?
Content
I need to create a PDF report of an incident and i need to attach this to incident.
When I run a analytic custom report from the php script code, the report's result is in array format. There is a rightnow function (such as getDataXML(), getDataHTML()...) that convert this array result into a PDF file? Or exist a library for create a PDF files in OSC with a documentation?
Thank you in advance!
Version
Oracle Service Cloud May 2017 SP4Code Snippet
$report_id=100053;
$status_filter= new RNCPHP\AnalyticsReportSearchFilter;
$status_filter->Name = 'Project Reference Number';
$status_filter->Values = array( $incident->ReferenceNumber );
$filters = new RNCPHP\AnalyticsReportSearchFilterArray;
$filters[] = $status_filter;
$ar= RNCPHP\AnalyticsReport::fetch( $report_id);
$arr= $ar->run( 0, $filters );
for ( $i =$arr->count(); $i-- ;)
{
$row = $arr->next();
$obj_array[] = $row;
}
//$obj_array contain the result of report
//HERE : The function for export result into PDF format
$fileName="ProjectReport.pdf";
$fattach = new RNCPHP\FileAttachmentIncident();
$fattach->ContentType = "text/plain";
$file_content = //the content of ProjectReport.pdf.
$fp = $fattach->makeFile();
fwrite($fp,$file_content);
fclose($fp);
$fattach->FileName = $fileName;
$fattach->Name =$fileName;
$incident->FileAttachments[] = $fattach;
Tagged:
0