web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Create a record in parent data source only when a record is created in child data source

(0) ShareShare
ReportReport
Posted on by

Hi,

I have a simple list detail form which has two data sources. One is Parent data source name 'A' and other one is linked Active with 'A' called 'B'. 

I have a requirement that record cannot be saved in data source 'A' until and unless at least one record exist in data source 'B' corresponding to the parent record. 

For this, I override the validateWrite method of data source 'A' and placed a condition that if record does not exist in data source 'B', it will return false. But by doing this, I am getting an issue that when ever I try to create a record in data source 'A' and proceed to create record in data source 'B', it gives me an error that at least one record need to be exist in data source "B' to save record in data source 'A'.

Any suggestions/solution on how to solve this?

*This post is locked for comments

I have the same question (0)
  • Amir Nazim Profile Picture
    5,994 on at

    Hi You have to study Unit of work framework in dynamics ax 2012. which allow u to same number of records in single transaction

    bit if details about the framework i collected below.

    Unit of work is a new framework that have been introduced in Ax 2012 that enables the number of records to be committed in single transaction. There are number of posts on this post that you can find easily in different blogs which talks about the unit of work framework implementation through code, however today in this post, I will be discussing the steps needed to implement the Unit of work for a Form and these steps are pretty simple.

    Before starting, I would like everyone to note that unit of work on a Form only works for inner join and outer joins records which means if you have two data sources with relationship other than inner join and outer join among them, the unit of work would not work for these data sources and the kernel will treat them in the standard way and to be specific these records will be saved in separate transaction

    Steps to enable unit of work

    1. Right click the data sources node in the Form and click properties to set the ChangeGroupMode to ImplicitInnerOuter.

    2. Then set the data sources joins

    3. Last step is to set the optional record mode. This step is set by default but The user can also control it. The property is responsible for controlling the create and delete behavior. You can do this by right clicking the specific data source and by choosing the property named as "OptionalRecordMode". This property can have three values

    · ImplicitCreate – creates the record if it isn’t defined and deletes it if the user doesn’t provide any values; used for singleton compositions where the data isn’t required

    · ExplicitCreate – requires the user to take some action (e.g. checkbox) to create the record; used when the existence of the optional record has some business impact

    · None – record is left null and fields aren’t editable; used for association relationships

  • Muhammad Usama Aziz Profile Picture
    on at

    This framework only works when we have 2 data sources that are inner joined or outer joined to each other. In my case the two data sources are linked 'Active' with each other.

  • Daniyal Profile Picture
    10 on at

    Set datasource property "ChangeGroupMode" to implicitInnerOuter

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans