Dear Experts,
I have make a code for send a notification to user, if Purchase order is rejected. This code is applied on "Request to Approve" page on "Reject Button". I am unable to filter the purchase order here. Because, if any sales order is rejected then the same mail is going to sales order creator person. What i need to add the extra filter here? Please help me. This code is work only for "Purchase order document" only not for sales order.
My code is below.
RejectionMailtoSendor(VAR RecAppEntry : Record "Approval Entry")
AE.RESET;
AE.SETRANGE("Document Type",RecAppEntry."Document Type");
AE.SETRANGE("Document No.",RecAppEntry."Document No.");
AE.SETRANGE(AE."Table ID", 38);
AE.FINDFIRST;
IF RecUserID.GET(RecAppEntry."Sender ID") THEN;
Mail.CreateMessage('MKU Limited','nav-uat@mku.com','','Rejected PO No.: '+ RecAppEntry."Document No.",'',TRUE);
Mail.AppendBody('Dear Sendor,');
Mail.AppendBody('<br><br>');
Mail.AppendBody('Your Purchase Order has been rejected, please read the comment carefully:');
Mail.AppendBody('<br>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');
Mail.AppendBody('<th>PO No.</th>');
Mail.AppendBody('<th>Comments</th>');
Mail.AppendBody('</tr>');
IF RecUserID.GET(RecAppEntry."Sender ID") THEN
Mail.AddCC(RecUserID."E-Mail");
AE.RESET;
AE.SETRANGE("Document Type",RecAppEntry."Document Type");
AE.SETRANGE("Document No.",RecAppEntry."Document No.");
IF AE.FINDLAST THEN BEGIN
REPEAT
Mail.AppendBody('<tr>');
Mail.AppendBody('<br>');
Mail.AppendBody('<td align="left">'+FORMAT(AE."Document No.")+'</td>');
ApprovalCommentLine.RESET;
ApprovalCommentLine.SETRANGE("Document No.", AE."Document No.");
IF ApprovalCommentLine.FINDLAST THEN BEGIN
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalCommentLine.Comment)+'</td>');
END;
Mail.AppendBody('</tr>');
UNTIL AE.NEXT = 0;
END;
Mail.AppendBody('</table>');
Mail.AppendBody('<br>');
Mail.AppendBody('Regards');
Mail.AppendBody('<br>');
Mail.AppendBody('MKU Navision(ERP) System');
Mail.AppendBody(' ');
Mail.AppendBody('<br><br>');
Mail.Send;
![]()