How to send Email Notification to Users using Workflow.

Hi Readers! Hope you like my blogs. Do give your valuable feedback in the comments section or you can email me via contacts on my blog site https://chrisdsilvablog.wordpress.com

Introduction:

Many a times in an Approval workflow, we need to notify the user by email to the Approver that approval request is sent also the sender needs to be notified whether the approval request sent is approved or cancelled. Hence, we need to setup Email Notification.

Read More »

Advertisements

How to send Notes to the Customer from a Custom Page using an Action button in Dynamics NAV

Introduction:

The requirement is explained in the Scenario below:

Scenario:

A Custom page called Collection Module-Per User has details of Customers Transaction. This Collection Per User page is a List page. The User will select the line and Click on Notes. Notes will written and saved. The user will Click on the Action button Send Notes to Customer.The Notes from this Custom page should be sent to standard page Customer (Page 18)

Read More »

How to Send Mail with attachment using Streams for reports with request page in Dynamics NAV

Introduction:

Scenario:

On Customer Master page, an action button is created called Email customer, on click of the action button, an email has to be sent to the respective customer with attachment of the invoices in a .pdf format. Here, the report is saves as .pdf file.

This report has a request page where Start Date and End date are entered by the user. Based on the date ranges, invoices generated for the particular user is mailed to the customer.

Pre-requisites:

Microsoft Dynamics NAV 2017

Steps:

  1. Create a global function on the Customer master page to make a call to the codeunit. Here the Customer No. is passed as a parameter.

1

2. In the Function InvoiceMail, declare a parameter  CustNo. and the variables as follows:

2

Here CustTempTable is a Temporary table

3

The Code is added as follows:

InvoiceMail(Custno : Code[20]) -Function Name
SMTPMailSetup.GET;

CustomerTable.RESET;
CustomerTable.SETRANGE(“No.”,Custno);
IF CustomerTable.FINDFIRST THEN BEGIN
EmailID:=CustomerTable.”E-Mail”;
CF_FTLCustomerInvoice.SETTABLEVIEW(CustomerTable);
XmlParameters:=CF_FTLCustomerInvoice.RUNREQUESTPAGE();
CustTempTable.Parameters.CREATEOUTSTREAM(OStream,TEXTENCODING::UTF8);
CustTempTable.Parameters.CREATEINSTREAM(IStream,TEXTENCODING::UTF8);
REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream);

CLEAR(SMTPMail);
SMTPMail.CreateMessage(”,SMTPMailSetup.”User ID”,EmailID,’Invoice Statement from CompanyName‘,”,TRUE);
SMTPMail.AddAttachmentStream(IStream,’Customer Invoice’+ CustomerTable.Name+’.pdf’);
SMTPMail.AppendBody(‘Hi ‘+CustomerTable.Name+’,’);
SMTPMail.AppendBody(‘<br>’);
SMTPMail.AppendBody(‘Please find attached your Customer Invoice statement’);
SMTPMail.AppendBody(‘<HR>’);
SMTPMail.AppendBody(‘This is a system generated mail. Please do not reply to this mail!’);
SMTPMail.Send;
MESSAGE(‘Mail sent to Customer %1’,Custno);
END;

Explaination of the code:

1. Set the SMTL Mail setup in the Role Tailored Client. Click on Apply Office 365 Server Settings. Add the Sender email (comapny email in my case) in User ID field and password of the email id in the Password field.

5

2. Store the Customer Email in the Email ID variable.

3. Pass the filters applied to the CustomerTable to the report variable CF_FTLCustomerInvoice.

4. Run the request page. The Run request page passes the request parameters in an xml format which is stored in a text variable XmlParameters.

5. Create an OutStream to save the the XmlParamters received in a File Parameters in a .xml format.

6. Create Instream to read the .xml file.

7. REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream); saves the xmlparameters from the outsream in an pdf format.

8. Use SMTPMail.CreateMessage function to enter the sender’s and receipient’s  email, Subject  etc.

9. Add the attachement from the InputStream.

10. Draft a body of the email and Use SMTPMail.Send to Send the email. Yay.Email is Sent!

Execution:

1.Click on Action button, Request page opens.

7

2. Enter the Start date and End date and click on OK.

8

3. An email is sent to the customer.

6

Conclusion:

Overview of the blog, first setup the SMTL Mail setup. Create an action button and create a function call. In the function defination, code as above and email is sent

 

 

How to update the selected line in the Subform on click of an action button in the Mainform in NAV

Introduction:

  • The requirement was such that , the user will select a line in the subform.
  • The subform has fields like the Customer ID, Customer Name, and a field Recieved Crates.
  • On click of the action button in the Main form, a page opens which contains the details of the selected line in the subform  like Customer ID and Customer Name also a field Crate recieved(Integer Datatype).

Read More »

How to restrict an action button based on time in Microsoft Dynamics NAV?

Introduction:

Scenario:

The requirement was such that on click of the action button a payment transaction is done. The time at which transaction was done is stored in the database. A restriction shouldto be applied to disallow the customer to make payment for the same amount till a certain time

E.g. A transaction was  done by customer A at 11.40 a.m for amount $100. This customer will be disallowed to make the transaction of the same amount $100 till suppose 5 mins. This time is mins will depend on the client requirement.

Read More »