Topic by Pramod V
Content
Hi Folks,
I am trying to fetch an Incident attachment and send it as an email to an external customer(mimicing the behaviour of Forward Incident info).
But I find that neither file_get_contents or getAdminURL seems to work. Is there any other way to fetch Incident attachment in CPM?
I have tried following code:
$inc_file_atachments = $obj->FileAttachments;
if($inc_file_atachments)
{
foreach($inc_file_atachments as $each_inc_file_atachments)
{
$fattach = new RNCPHP\FileAttachmentCommon();
$fattach->ContentType = $each_inc_file_atachments->ContentType;
$fp = $fattach->makeFile();
$filecontent = file_get_contents($each_inc_file_atachments->URL);
fwrite( $fp,$filecontent);
fclose( $fp );
$fattach->FileName = $each_inc_file_atachments->FileName;
$fattach->Name = $each_inc_file_atachments->FileName;
/*$fattach = new RNCPHP\FileAttachmentCommon();
$fattach->ContentType = $each_inc_file_atachments->ContentType;
$fattach->FileName = $each_inc_file_atachments->FileName;
$fattach->Data = $each_inc_file_atachments->URL;*/
}
}
Nothing seems to work and I have embedded logs, file attachment data appears null. Not sure where I am going wrong, but I have done following checks:
- Valid Incident ID
- AN Incident with File Attachment
- Trigger of CPM confirmed from Audit Log
Please assist.
- VIP