web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Sending email with attachment to the vendor after the status is approved

(0) ShareShare
ReportReport
Posted on by 4,188

Hi

I'm using Purchase order send approval workflow. once the approval request is approved by the approver i.e status of approval entries changes to Approved. An email with purchase order details as an attachment should be sent to the Vendor.

I've written code for the email with attachment but how to trigger this code? 

can someone help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    AJAnsari Profile Picture
    5,754 on at

    Workflows in Dynamics NAV are based on the Event -> Condition -> Response model. From what you're describing, what you need is to develop a custom Response that would trigger your code.

    Once the response is created, you can map it to one or more Events using the Workflow Event/Response combinations page. This would allow you to use your new response within a Workflow in conjunction with the desired Event.

    This MSDN article should help if you are not familiar with how to create a Custom Response (or a Custom Event, should you ever need to create one: msdn.microsoft.com/.../mt574349(v=nav.90).aspx

    I hope this helps. If my response has answered your question, please verify it by clicking Yes next to "Did this answer your question?"

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello Chris,

    See the bellow links, and follow the procedures, definitely you can do .

    Walkthrough: Implementing New Workflow Events and Responses for Sales Header on Delete Record

  • CDsilva Profile Picture
    4,188 on at

    Hi

    I created a workflow response for 'Purchase order send approval workflow' and added it to the workflow in the front end. I need to attach the document as .pdf file. I've written the below code but it work if I use it normally without a workflow i.e on a Action. but doesn't work with the workflow. 

    email.JPG

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello Chris,

    Better to use FileMgmt Codeunit for copying the server file in to client.

    or you can use bellow solution as per ur requirements

    OR use for saving

    FileName := FileMgt.ClientTempFileName('PDF');

    //Bellow code are working.,

    IF YourReport.SAVEASPDF(TotalFileNameL) THEN BEGIN

     COMMIT;

     IF FileMgt.ClientFileExists(TotalFileNameL) THEN BEGIN

       SendMailTest('WIRE',MonthL,TotalFileNameL);

     END  ELSE

       ERROR(Text012,TotalFileNameL);

    END ELSE

     ERROR(Text013);

    //Find the screenshot for SendMail. its working

    2627.2.png

    2627.2.png

  • CDsilva Profile Picture
    4,188 on at

    Hi Binesh,

    I'm finding the above post difficult to understand. can you please explain it again.

    I need to get the purchase order number and then attach the purchase order as a pdf document.

    can you tell me what modification need to be done to my code. cause my code works successful without using workflows.

  • Verified answer
    Binesh Profile Picture
    7,885 on at

    Hello Chris,

    I Checked in my DB with Sales Header, its working, See the bellow Image.

    Do one thing Debug your code, it might be chances to:

    >   Not getting the Purchase Order No.

    > IF in your PO no records then, system won't create PDF also.

    > Better to filter one PO like me that are exist and then try it.

    > also check in PO no, is any special char or spaces in last.

     

    1805.2.png

    1805.2.png

  • CDsilva Profile Picture
    4,188 on at

    Hi Binesh

    Thanks for you reply. My code fetches the purchase order number and also mail is sent successfully but when I open my pdf document in the mail. I receive details of all purchase orders.

    is there any means to filter and send only details of my purchase order in the pdf rather than sending all.

  • CDsilva Profile Picture
    4,188 on at

    email1.JPG

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello Chris,

    How you called SendEmailWithAttachment, Send your code, because you are passing the Purchase header, 

    and if you didn't filter correctly, then it pulled all records.

    You have to filter purchase Header with particular no. or whatever you want, that's it.

  • CDsilva Profile Picture
    4,188 on at

    Hi Binesh,

    I followed your code and called my function from purchase order form action for testing purpose. 

    still in my pdf I get record details of all purchase orders.

    5516.email2.JPG

    5516.email2.JPG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans