Friday, September 14, 2018

D365/AX7 – How to use Change Group and Optional Record Mode properties

When a record needs to be created, updated or deleted in a form data source based on the joined form data source, we can achieve this using ChangeGroupMode and OptionalRecordMode properties on form and form data source respectively.

Problem

Consider two tables TaskTable and CriticalTask, such that the CriticalTask table contains the foreign key relation with TaskTable. We need to create record in CriticalTask table if the checkbox is marked check.

Solution

Follow the steps below to create/delete a record based on joined table.

Step#1 Create tables MY_TaskTable and MY_CriticalTask with a Normal relation between two tables.


Step#2 Add the tables MY_TaskTable and MY_CriticalTask to the form.

Step#3 Set the property Data Source Change Group Mode to ImplicitInnerOuter to use a change group for the tables in the form data source.



A change group is a set of joined tables in a form data source. The change group uses UnitOfWork framework to implement database transaction, such that if create, update or delete fails for any of the tables in change group, the change is rolled back for all the tables in the group. For further information regarding Change Group Mode property, see Change Group and Optional Record Modes.


Step#4 On form data source for MY_CriticalTask, the Link Type must be set to OuterJoin to use optional record mode. Set the property Optional Record Mode to ExlicitCreate.

               

Setting the Optional Record Mode to ExpliciteCreate, we use a check box control to explicitly specify whether to create or delete the joined record. If the check box is selected, the record is always created. If the check box is cleared, the record is always deleted. For further information regarding Optional Record Mode property, see Change Group and Optional Record Modes.

Step#5 Add a checkbox on form and set the Data Source to MY_CriticalTask and Optional Record Control to Yes. This check box will work as a command to create a record in table MY_CriticalTask for the respective MY_TaskTable record.




Execution

It can be now observed on form that when the check box for Critical task is marked checked, a record is added to the MY_CriticalTask table for the selected MY_TaskTable record. Whereas, on unchecking the checkbox, the record is deleted from the MY_CriticalTask table for the selected MY_TaskTable record.

Wednesday, September 12, 2018

D365/AX7 – Adding conditional check box on SSRS report design


Problem

There are several requirements to add checkbox to the SSRS report design and mark it checked or unchecked based on some condition. Let’s look at the steps to add checkbox.

Solution

In order to show the checkbox marked check and unchecked based on some condition, follow the steps below.

Step#1 Insert a textbox or create a placeholder on report

Step#2 Set the font style of the textbox/placeholder as Wingdings

Step#3 Add below expression to the text box or the placeholder.
=IIF(Fields!IsEmployed.Value = "No", chr(254), chr(168))

Here,
Chr(254): Displays checked checkbox  รพ
Chr(168): Displays unchecked checkbox c