Recently I came across a requirement where in I had to print AX 2012 collection letter report in PDF format and attach it to a mail Item and send it across to the customer. The requirement here was that this functionality has to be triggered on a click of button which was pretty normal but the real catch here was that the email ID should be fetched from the customers print job settings and not a normal setup, In standard system these settings can vary according to journals. I did some research and found out a way to find print job settings of customer for collection letter journal Report. Here is the code, you can use this code for finding print job settings of many important system reports such as Invoice etc....
Static void findPrintJobSettings(Args _args)
{
FormLetterReport formletterReport;
PrintMgmtPrintSettingDetail settingDetail;
SRSPrintDestinationSettings destination;
CustCollectionLetterJour jour;
CustTable custTable;
select jour where jour.RecId == 11290923078;
select custTable where custTable.AccountNum == "2014";
formLetterReport = FormLetterReport::Construct(PrintMgmtDocumentType::
CustCollectionLetter);
formLetterReport.
formLetterReport.loadPrintSettings(jour,custTable,
jour.LanguageId,
jour.CollectionLetterNum);
while(formletterReport. moveNextPrintSetting())
{
settingDetail = FormLetterReport. getCurrentPrintSetting();
destination = settingDetail.
print destination.printMediumType();
print destination.emailTo();
print destination.numberOfCopies();
pause;
}
}