- Print
- PDF
Use Alerts to Trigger a Report-Execution
Lasernet Query reports can be automatically triggered using Alert links. Alert links link Alerts in standard Dynamics 365 Finance and Operations to Lasernet Query reports.
This is useful in situations in which no report exists for a process/flow, when there is a need to trigger a report once a record is deleted, inserted or when a value for 'Field is changing' (such as when an order-status) is changing.
Other examples are:
There is a need to trigger a report once a credit max/limit is changed.
There is a need for an additional report execution such as a label when an order-status is changing.
Note
Alert links work with custom queries only and not with replacement reports. That is per design since the replacement reports have a point of execution as the process that starts these reports is the posting and journal.
A custom alert can be created on any form (Purchase orders, Sales orders, etc) by navigating to the Action pane > Options tab > Share group > Create a custom alert.
In the following example, we will create an alert from the Purchase orders list page. To do so, navigate to Accounts payable > Purchase orders > All purchase orders.

Create Custom Alert
To create a custom alert, follow these steps:
Click Create a custom alert: a window will open.

You can either use All fields or select a specific field.

Selecting All fields would allow the user to select either the Event Record has been created or Record has been deleted. The event Record has been created would prepare an Alert once a record is inserted, while Record has been deleted would prepare an Alert once a record is deleted within the selected table.

Selecting a specific field would provide some additional events.
Example
Selecting a field like Customer reference, for example, would provide the following option for an Event:

Link the Alert with a Report in Lasernet FO Connector
Linking an Alert with a report in Lasernet FO Connector can be achieved in two ways.
First method:
Open Manage my Alerts from any Dynamics 365 Finance and Operations form by navigating to the Action pane > Options tab > Share group > Create a custom alert. This is a standard form that will show all your Alerts.

Link to the report in Lasernet FO Connector. In the Alert with Reports FastTab, add a record to the report in Lasernet FO Connector.

Second method:
Navigate to Lasernet > Common > Reports > Setup > Alert links.

Set Up the Link to the Alerts in Lasernet FO Connector
The Alert links form can be accessed both from Lasernet > Common > Reports > Setup > Alert link, and from Accounts receivable > Customers > All customers > Options > Manage my alerts > Setup.
To set up the link to the Alerts, follow these steps:
Select the Rule Id that was created through the Create a custom alert option, and toggle the Active button to Yes.

Select the required Destination.

Alerts are a backend process and Lasernet screen is therefore not allowed as a destination.
The following warning is displayed when the Lasernet screen is used as a destination for the Alert:

Warning
Unable to execute Lasernet report VendPurch_BalanceCheck on event 000302, as screen or standard destinations are not allowed in event links
Select Default ranges in the Records to Include FastTab. The Default ranges define which record to include when the report is automatically run. They work in a similar way to the Form links in Lasernet FO Connector.

In the Default query ranges dialog, either locate or add the fields that will be used as a ranges. Provide a Range for the specified field. Selecting a value from the dropdown hardcodes the range to a specific value, while clicking the Expression editor button provides the option to dynamically set the range value.

Context in Lasernet FO Connector when Working with an Alert
Alert links can use the value Context within Default ranges. Context provides information about the Alert and also contains information about the record that triggered the Alert. This is useful because using Context will dynamically identify the record for which the alert was triggered and the query will automatically run based on this value.
Open the Default ranges for an Alert link and select the Expression button on the desired field to open the expression editor. (Review last step from previous section).

Open the dropdown on the Select Value field and select Context.

Open the dropdown again to see the EventLink list. Select the EventLink associated to your Rule ID.

Selecting the Rule Id provides information about the Alert and the table triggering the Alert – the table PurchTable is shown in the following image:

Open the dropdown again to see the fields list for the selected table. Select the field associated with your range. The following example illustrates a report range in which the field PurchID is used from the record that triggered the Alert:

Select OK to close out of the Expression editor. The PurchID from the Context will be used so that only records that have the same PurchID as the record triggering the Alert will be fetched.

Note
It is possible to specify default query ranges for a report with more than one criterion.
For example, if an alert needs to be associated with a specific purchase order (which is associated with a vendor account), it can be specified as follows:

This approach is recommended over creating two alert link rules with conditions as only one condition is possible by design per Alert rule in Dynamics 365.
Context - EventType
Context provides information about the Alert and also contains information about the record that triggered the Alert. The previous steps guided us on how to use Context to pull in information regarding the table and field triggering the alert. Alternatively, Context can also retrieve information using EventType.
The EventType makes it possible to retrieve information about the Current and Original Value.
This is useful when triggering an Alert through a specific field, such as Credit max, Status field, Delivery date, or any other fields.

Use the Context.EventLink_xxxx.EventType.parmCurrentValue() and parmOriginalValue() to retrieve the Current or Original from a previously changed field.

Required Batch Jobs for Alerts
Ensure the following batch tasks are running as they are used for the Alerts in standard Dynamics 365 Finance and Operations:
Change-based alerts:

Due date alerts:

In case any batch job has not started, it is possible to start them from System administration > Periodic tasks > Alerts. A Recurrence, such as every two minutes, must be set so Alerts are processed regularly.

The batch jobs are a standard Dynamics functionality that will process and generate Alerts regularly as set by the recurrence. The Lasernet query is generated when the batch job runs, and the alert is generated. If archiving is enabled, the generated Lasernet Query can be seen in the Lasernet Archive.