Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Workflows

(0) ShareShare
ReportReport
Posted on by 4,184

I want to know the difference when should I used workflows and when to use codeunits?

Like e.g Email notification to customers about sales order

Which is more efficient writing a codeunit or workflow?

*This post is locked for comments

  • Binesh Profile Picture
    Binesh 7,885 on at
    RE: Workflows

    for that i'll create a doc. and update you.

    till now you can practice with this workflow [This workflow fire if any record deleted]

    so based on you can try.

  • CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Workflows

    Hello @Binesh

    i want sent email notification to the customer using workflows hence i follwed your link

    sbinesh.blogspot.in/.../walkthrough-implementing-new-workflow_21.html

    how to cal a function when it is Local function.

    i used Codeunit.Run for it. the problem still exist

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Workflows

    Hello,

    Write your code in any codeunit, and that codeunit.function call to your sales order page i.e. 42.

    See the bellow screenshot.

    2016_2D00_10_2D00_27_5F00_15_2D00_15_2D00_07.png

    Whenever you click on Release action, and once the release action done then your code will fire and emailed.

  • CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Workflows

    @Binesh

    Also can you tell me how did you call the codeunit using workflows

  • CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Workflows

    @Binesh i followed your link

    sbinesh.blogspot.in/.../walkthrough-implementing-new-workflow_21.html

    only in sendemail if inserted the following code sice i need to take the respective customers email address

    LOCAL SendEmailOnRelease(SalesHeader : Record "Sales Header") : Boolean

    WITH SalesHeader DO BEGIN

     SalesLine.RESET;

     SalesLine.SETRANGE("Document No.","No.");

     IF SalesLine.FINDFIRST THEN

       REPEAT

         Customer.RESET;

         Customer.SETRANGE("No.",SalesLine."Sell-to Customer No.");

         IF Customer.FINDFIRST THEN

           CustEmail:=Customer."E-Mail";

       SMTPMailSetup.GET;

       FileName:=FileManagement.ServerTempFileName('pdf');

       REPORT.SAVEASPDF(205,FileName,SalesHeader);

       SMTPMail.CreateMessage('',SMTPMailSetup."User ID",CustEmail,'Sales Order is Released','',TRUE);

       SMTPMail.AddAttachment(FileName,SalesHeader."No."+'.pdf');

       SMTPMail.AppendBody('Dear Sir/Madam');

       SMTPMail.AppendBody('<br><br>');

       SMTPMail.AppendBody('Please find the attachment');

       SMTPMail.AppendBody('<br><br>');

       SMTPMail.AppendBody('<HR>');

       SMTPMail.AppendBody('This is system generated mail.Please do not reply to this EmailID');

       SMTPMail.Send;

       UNTIL SalesLine.NEXT=0;

       MESSAGE('Mail sent to Customer');

       END;

    EXIT(TRUE);

    the email is not sent and another problem is while creating new sales order, when i select the customer. the event fires

    and message of email is sent is displayed

    Can you help me with this

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Workflows

    Hello,

    Workflows in Dynamics NAV focus on three main building blocks and almost any workflow process, short or long, is likely to be comprised of steps related to these three blocks.  They are:
    • Approval, approval leaves a work task, item or document in an blocked or unapproved state until approved by a suitable person in your organization
    • Notification, notifications tell users that something has happened and/or that they need to take some kind of action
    • Process automation, process automation means executing a process routine and have the Dynamics NAV system calculate something or perform an action.

    Or In Short workflow is a example of "Request and Response"

    For more Info Click Here

    > Writing a codeunit is a big headache or time consuming, But using workflow its simple and reliable. 

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Workflows

    I think it depends on the requirement  but I would suggest you to discover how workflow works and how it is useful in your business process.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans