Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
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 230,235 Most Valuable Professional 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,278 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans