Use Notification Management to create an email-button on a Sales Order Page

The purpose of this blog is to show how you can send an email, directly from a NAV page, using Notification Management. By taking some simple steps, we lead you in this blog to the results of an efficient To-Increase Solution, with a high-lever user experience.

Development Environment

Use the Dynamics NAV 2013 Development Environment to create a button on the Sales Order Page. Ensure you have full development access in the development environment by using a developer’s license.

  • Open the Development Environment.
  • Open the Object Designer, select the Sales Order page (Page ID = 42) and click on Design to open the Page 42 Sales Order Designer Page.
  • Click on View – Page Actions and scroll down to the ActionContainer with SubType ActionItems.
  • Add a new Action to this container. Define a name (Send Notification) and a caption (Notification). Click on View – Properties to open the properties window for this action.

1 Page - Action Designer

  • Select an applicable image, for example the ‘Email’ image. Set the promoted field to ‘Yes’ and PromotedCategory to ‘Process’. Close the properties window.
  • Press F9 to go to the C/AL editor and lookup the created Send Notification – OnAction. Click on View – C/AL Locals.
  • Define the OnAction local variables as shown in the image below. Thereafter close the OnAction

2 OnAction - CAL Locals

  • Add the following statements to the trigger:
CurrPage.SETSELECTIONFILTER(SalesHeader);
RecRef.GETTABLE(SalesHeader);
RegisterEvent.RegisterEvent(RecRef);
  • Close the page designer and save the object.
  • Run the page from the Object Designer by pressing the Run button. As you can see a new button is created an placed in the Ribbon of the Sales Order Page.

3 Email Button in the ribbon

Microsoft Dynamics

In our previous blogs we described the use of documents, both internal and external. For Notification Management we follow the same sequence of actions which should be taken to create a valid notification. For details we would like to refer to our blog about the To Increase’s Concept for Solution Center.

  • Create an internal document based on the example in this excel file.
  • Create a new notification and add the document to the notification.
  • Add the following elements to the notification:
    • User Event
    • XML Generator Activity
    • Splitter Activity
    • Header Mapper Activity
    • Attachment Generator Activity
    • XML to HTML Translator Activity
    • Outlook Writer Endpoint

Now we can configure each element. Therefore, select the Element and click on Edit.

User Event

This Event links to the Object which is created in the NAV Development Environment. Select ‘Page’ in the Object Type field and use the dropdown button to select the page you want to add to this element. In our case it will be ‘42’.

4 UI Event Setup

XML Generator Activity

The XML Generator Activity generates an xml-file, based on the internal document which is defined. Select the internal document in the Document No. field.

5 XML Generator Setup

Splitter Activity

The Splitter Activity splits an xml with more than one parent into several small xml-files. Select the internal document in the Document Type and Document No. fields.

6 Splitter Setup

Header Mapper Activity

The Header Mapper Activity adds headers to the xml-files. To define the correct headers, it is required to link this activity to an endpoint, in this case the Outlook Writer Endpoint. In the Document fast tab, select the internal document which is created and press TAB. In the Header Configuration fast tab it is possible to define the headers. Please use the lookup button to define the Expression fields as shown in the image below. If you’re using Outlook, it is not necessary to define a ‘to-expression’, because Outlook will use the default settings from your user account.

7 Header Mapper Setup

Attachment Generator Activity

The Attachment Generator Activity allows you to attach reports to the email you want to send. In this case we created the Notification Button on the Sales Order page, so it is logic to add the Sales Confirmation Report to this notification. It is possible to add reports three different formats: pdf, word and excel. Add the reports as shown in the image below.

8 Attachment Generator Setup

XML to HTML Translator Activity

The XML to HTML Translator Activity makes it possible to create an html template which is unique for your company. You can use the To-Increase Notification Editor (ensure you install the editor on the Client) to create an html, provided with the possibility to add NAV fields into this html. The image below shows our To-Increae template, which we use for a Sales Order Confirmation.

9 XML to HTML Translator Setup

Outlook Writer Endpoint

The Outlook Writer Endpoint is the final element in this notification. Using this endpoint makes it possible to email the created html + attachments, using Microsoft Outlook. The Outlook Writer Endpoint does not require specific settings to be made.

10 Outlook Setup

Pipeline

Now all the elements are configured, it is time to set up a working pipeline. To configure the pipeline, just add the elements into the Pipeline fast tab. Select the ‘from element’ and the ‘to element’ to create a proper sequence of elements. After the pipeline is set up, please press the Check Configuration button in the ribbon to ensure all the elements are configured on a right way.

11 Pipeline Configuration

Run the notification

To run the notification, go to the Sales Order page and open a Sales Order. Press the Notification button which you created and an Outlook window will be opened. In this window you see your html and attachments, in accordance with the selected Sales Order.

12 Message output

 

About Paresh Sharma

Product Consultant for To-Increase Business Integration Solutions| Support Consultant for To-Increase BIS and IEM Solution|Certified Scrum Master|Over 10 years of experience in IT Industry
This entry was posted in Notification Management, Solution Center and tagged , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a comment