How to attach BI Publisher Report to an email PeopleCode
How to attach BI Publisher Report to an email PeopleCode of PeopleSoft. Some requirement from user wants to send mail with attach file pdf, doc, and other from bi publisher report. You can use this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/*General code to print BI Publisher Report*/ import PSXP_RPTDEFNMANAGER:*; /* get report definition object */ &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn (&sRptDefn); &oRptDefn.Get(); &oRptDefn.OutDestination = "/" | GetCwd(); /*We can change this path, if needed*/ /* fill query runtime prompt record */ &rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord(); If Not &rcdQryPrompts = Null Then &oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts); End-If; &oRptDefn.ProcessInstance = &prcsInstId; /*generate report*/ &oRptDefn.ProcessReport (&sTmpltID, &sLangCd, &AsOfDate, &sOutFormat); /*Create URL ID before proceeding, use this link for the steps to URL ID */ &URL_ID = "record://RECORD_NAME"; /*We are changing the name of the report just make it possible to locate it*/ &oRptDefn.ReportFileName = "Report_Name"; /*Adding the extension of the file*/ &filename = "Report_Name"|"."|&sOutFormat; &source_file = &oRptDefn.OutDestination | &filename; &return = PutAttachment(&URL_ID, &filename, &source_file); /*publish report */ &oRptDefn.Publish(&sPrcsServerName,"",&sFolder, &prcsInstId); /*&sPrcsServerName and &sFolder can be "" (i.e. blank) and &prcsInstId is process instance of your process*/ /*As now we have the path for the report (i.e. &source_file), we can now use this to add this report as an attachment in our email, as shown below code*/ &dest_file = &source_file; /*SendMail() can directly access this file if application server and ftp server are at same location. If they are at different location, use GetAttachment() to get file from ftp server to application server and then mention the path of application server*/ &RET =SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC,&MAIL_SUBJECT, &MAIL_TEXT, &dest_file, &filename,&MAIL_FROM,&MAIL_SEP,&CONTTYPE,&REPLYTO, &SENDER); |
Reference : http://techatpeoplesoft.blogspot.com/2016/04/how-to-attach-bi-publisher-report-to.html