Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Auto generated child record when creating parent line

Posted on by 275

Hi

I have a created an alteration to SalesProjectQuotationLine (Parent) by creating an extra table (Child) which contains alot of extra infomation. 

But the line should only be created if the Parent type is a specific type. The problem is because of the innerjoin on the datasource level, the line are created automatically. I have tried to alter Write (Form method), ValidateWrite (Form method), InitValue (Form method), OnCreating (Form event method), OnInitValue (Form event method), OnValidatingWrite (Form event method), Insert (Table method), Update (Table method), InitValue(Table method) But none of the methods are called before the line are created.

How can i prevent the Parent inserting a new record on the child? Or atleast creating my if before the line are created.

Sinceryly AShein

  • Ashein Profile Picture
    Ashein 275 on at
    RE: Auto generated child record when creating parent line

    Thanks Martin, this worked exactly the way i should.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: Auto generated child record when creating parent line

    An inner join sounds like a bad choice if the related record will exist only for certain header. The inner join would filter out all headers that don't have that, i.e. all header except of those of your specific type.

    Consider using a link (such as Delayed) instead of a join, or using an outer join. Then you can create the line from code (or, in case of outer join, let the system to create a line automatically when one of its fields get changed).

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,274 on at
    RE: Auto generated child record when creating parent line

    skip super() in write if you dont wont to save it and then return true from validateWrite to avoid warnings.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans