Dear All,
In approval time, is there any way we can send the Purchase order rejection mail to the Purchase order creator in Navision 2016. Please give me some idea to develop it.
*This post is locked for comments
Dear All,
In approval time, is there any way we can send the Purchase order rejection mail to the Purchase order creator in Navision 2016. Please give me some idea to develop it.
*This post is locked for comments
Check whether you are getting email id in variable from User Setup table by using debugger..
I am trying with your suggestion but always, it is saying the "The email address is not valid.". What I am doing wrong in this code, firstly I am getting the email address from user setup and then after sending the email through page 654. In this page I have call the function(POrejectionConfirmation.) on reject button. on ribbon section.
Change the Code as below shown in Red Line which will resolve your error
ApprovalEntry.RESET;
ApprovalEntry.SETRANGE(ApprovalEntry."Approver ID", UserSetup."User ID");
ApprovalEntry.SETRANGE(ApprovalEntry."Sender ID", UserSetup."User ID");
IF ApprovalEntry.FINDFIRST THEN;
// FOR PO Creator Email id
IF UserSetup.GET(ApprovalEntry."Sender ID") THEN
POCreatoremailid :=UserSetup."E-Mail";
//FOR PO Approver email id
IF UserSetup.GET(ApprovalEntry."Approver ID") THEN
POApproveremailid :=UserSetup."E-Mail";
Mail.CreateMessage('MKU Limited','nav@abc.com','POApproveremailid','Purchase Order Rejection Notification','',TRUE);
Mail.CreateMessage('MKU Limited','nav@abc.com',POApproveremailid,'Purchase Order Rejection Notification','',TRUE);
Mail.AddCC(POCreatoremailid);
Mail.AppendBody('Dear Sir / Madam,');
Mail.AppendBody('<br>');
Mail.AppendBody('Rejected Purchase Order Details are below:');
Mail.AppendBody('<HR>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');
Mail.AppendBody('<th>Purchase Order No.</th>');
Mail.AppendBody('<th>Amount</th>');
Mail.AppendBody('<th>Amount (LCY)</th>');
Mail.AppendBody('<th>Vendor</th>');
Mail.AppendBody('<th>Due Date</th>');
Mail.AppendBody('<th>Comments</th>');
Mail.AppendBody('</tr>');
ApprovalEntry.RESET;
ApprovalEntry.SETRANGE(ApprovalEntry."Table ID",38);
IF ApprovalEntry.FINDSET THEN BEGIN
REPEAT
Mail.AppendBody('<tr>');
Mail.AppendBody('<br>');
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalEntry."Document No.")+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(ApprovalEntry.Amount)+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(ApprovalEntry."Amount (LCY)")+'</td>');
PurchaseHeader.RESET;
PurchaseHeader.SETRANGE("No.", ApprovalEntry."Document No.");
IF PurchaseHeader.FINDFIRST THEN BEGIN
Mail.AppendBody('<td align="left">'+FORMAT(PurchaseHeader."Buy-from Vendor Name")+'</td>');
END;
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalEntry."Due Date")+'</td>');
ApprovalCommentLine.RESET;
ApprovalCommentLine.SETRANGE("Document No.", ApprovalEntry."Document No.");
IF ApprovalCommentLine.FINDFIRST THEN BEGIN
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalCommentLine.Comment)+'</td>');
END;
Mail.AppendBody('</tr>');
UNTIL ApprovalEntry.NEXT = 0;
END;
Mail.AppendBody('</table>');
Mail.AppendBody('<HR>');
Mail.AppendBody('<br>');
Mail.AppendBody('Regards');
Mail.AppendBody('<br>');
Mail.AppendBody('MKU Navision(ERP) System');
Mail.AppendBody(' ');
Mail.AppendBody('<br><br>');
Mail.Send;
Hi,
You can create a new function in a codeunit with Event: Subscriber, EventPublisherObject: Codeunit Approvals Mgmt. and event function 'OnRejectApprovalRequest' and add the following code as shown in the below screenshot:
You can read the following link to send email using C/AL code:
https://saurav-nav.blogspot.in/2013/08/send-mail-with-attachment-from-navision.html?m=1
Dear Sir,
I have prepared the code for this activity but it is always saying:
My written code is below:
ApprovalEntry.RESET;
ApprovalEntry.SETRANGE(ApprovalEntry."Approver ID", UserSetup."User ID");
ApprovalEntry.SETRANGE(ApprovalEntry."Sender ID", UserSetup."User ID");
IF ApprovalEntry.FINDFIRST THEN;
// FOR PO Creator Email id
IF UserSetup.GET(ApprovalEntry."Sender ID") THEN
POCreatoremailid :=UserSetup."E-Mail";
//FOR PO Approver email id
IF UserSetup.GET(ApprovalEntry."Approver ID") THEN
POApproveremailid :=UserSetup."E-Mail";
Mail.CreateMessage('MKU Limited','nav@abc.com','POApproveremailid','Purchase Order Rejection Notification','',TRUE);
Mail.AddCC(POCreatoremailid);
Mail.AppendBody('Dear Sir / Madam,');
Mail.AppendBody('<br>');
Mail.AppendBody('Rejected Purchase Order Details are below:');
Mail.AppendBody('<HR>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');
Mail.AppendBody('<th>Purchase Order No.</th>');
Mail.AppendBody('<th>Amount</th>');
Mail.AppendBody('<th>Amount (LCY)</th>');
Mail.AppendBody('<th>Vendor</th>');
Mail.AppendBody('<th>Due Date</th>');
Mail.AppendBody('<th>Comments</th>');
Mail.AppendBody('</tr>');
ApprovalEntry.RESET;
ApprovalEntry.SETRANGE(ApprovalEntry."Table ID",38);
IF ApprovalEntry.FINDSET THEN BEGIN
REPEAT
Mail.AppendBody('<tr>');
Mail.AppendBody('<br>');
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalEntry."Document No.")+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(ApprovalEntry.Amount)+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(ApprovalEntry."Amount (LCY)")+'</td>');
PurchaseHeader.RESET;
PurchaseHeader.SETRANGE("No.", ApprovalEntry."Document No.");
IF PurchaseHeader.FINDFIRST THEN BEGIN
Mail.AppendBody('<td align="left">'+FORMAT(PurchaseHeader."Buy-from Vendor Name")+'</td>');
END;
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalEntry."Due Date")+'</td>');
ApprovalCommentLine.RESET;
ApprovalCommentLine.SETRANGE("Document No.", ApprovalEntry."Document No.");
IF ApprovalCommentLine.FINDFIRST THEN BEGIN
Mail.AppendBody('<td align="left">'+FORMAT(ApprovalCommentLine.Comment)+'</td>');
END;
Mail.AppendBody('</tr>');
UNTIL ApprovalEntry.NEXT = 0;
END;
Mail.AppendBody('</table>');
Mail.AppendBody('<HR>');
Mail.AppendBody('<br>');
Mail.AppendBody('Regards');
Mail.AppendBody('<br>');
Mail.AppendBody('MKU Navision(ERP) System');
Mail.AppendBody(' ');
Mail.AppendBody('<br><br>');
Mail.Send;
Hi
Create an Event Subscriber for Codeunit 'Approvals Mgmt.', Event 'OnRejectApprovalRequest'. In this new function create a Notification that will be sent via dispatcher on Job Queue:
NotificationEntry.CreateNew(NotificationEntry.Type::Approval,ApprovalEntry."Sender ID",ApprovalEntry,0,'');
Here 'NotificationEntry' is the record 'Notification Entry'.
You might also want to add checks that it's a PO, and not SO or journal.
Hope that helps.
Robertas
André Arnaud de Cal... 291,711 Super User 2024 Season 2
Martin Dráb 230,458 Most Valuable Professional
nmaenpaa 101,156