I want to find the all production order which are closed in last week. So I have created a separate codeunit but here I am unable to set the last week filter. My code is below:
CLEAR(Mail);
Mail.CreateMessage('Att India Limited','nav@att.com','nav.user@att.com','Last Week Closed RPO List.','',TRUE);
Mail.AppendBody('Dear Sir / Madam');
Mail.AppendBody('<br><br>');
Mail.AppendBody('Please Find Closed RPO List in Last Week');
Mail.AppendBody('<HR>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');
Mail.AppendBody('<th>RPO No.</th>');
Mail.AppendBody('<th>Due Date</th>');
Mail.AppendBody('</tr>');
ProductionOrder.SETRANGE(Status,4);
ProductionOrder.SETCURRENTKEY("Finished Date");
//ProductionOrder.CALCDATE('-7D',TODAY));
ProductionOrder.SETFILTER(FORMAT(CALCDATE('-7D',TODAY)));
IF ProductionOrder.FINDFIRST THEN
REPEAT
Mail.AppendBody('<tr>');
Mail.AppendBody('<td>'+FORMAT(ProductionOrder."No.")+'</td>');
Mail.AppendBody('<td align="center">'+FORMAT(ProductionOrder."Due Date")+'</td>');
Mail.AppendBody('</tr>');
UNTIL(ProductionOrder.NEXT=0);
Mail.AppendBody('</table>');
Mail.AppendBody('<br>');
Mail.AppendBody('Regards');
Mail.AppendBody('<br>');
Mail.AppendBody('ATT India Production Department');
Mail.AppendBody(' ');
Mail.AppendBody('<br><br>');
Mail.AppendBody('<HR>');
Mail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');
Mail.Send;