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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

how can we run our custom code just after creation of sales/purchase orders or project

(0) ShareShare
ReportReport
Posted on by 63

Hi

I have created one class for writing some custom code, I want to execute that methods in class just after creation of sales/purchase orders or just after creation of Project (like we filled details & hit create button just after that logic must be executed)

is their any specific methods or events on forms which let us execute our code just after these events.

Thanks,

Harshit

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    305,475 Super User 2026 Season 1 on at

    Hi Harshit,

    You can create event handler methods in a class which subscribes to the table OnInserted events for the tables which should trigger your coding.

  • Verified answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi Harshit, As Andre mentioned, you can create post event handler for table insert as specified in below article.

    www.d365snippets.com/.../event-han.html

    Also, you can use Chain of Command on table insert method

    https://dynamics365musings.com/chain-of-command-table-methods/

  • Anton Venter Profile Picture
    20,674 Super User 2026 Season 1 on at

    Hi,

    What is important to consider, is when your code should be executed. Because if all order lines should be processed, it doesn't make sense to add run the custom when the order header is inserted, but rather when the order is confirmed for example. Or some other process event.

  • Harshit Tyagi Profile Picture
    63 on at

    Hi Andre & Mohit,

    It worked, Thanks for sharing the Reference.

    Thanks,

    Harshit

  • Harshit Tyagi Profile Picture
    63 on at

    Hi Anton,

    Thanks for the suggestion.

    Yes I must consider this while creating a sales/purchase order but where I can add my logic, which event needs to subscribed.

    but what if I am creating a project & I need some fields from billing Rules lines (LineValue, Default Dimension) ) to create journal lines for a journal , In that case I can execute the logic just after creation of project Header because for that I just need ProjId & ProjInvoiceProjId of newly created project, with these data I can easily fetch the Billling Rules from PSAContractLineItems Table.

    So, Is it not feasible to run my logic in OnInserted event of ProjTable.

    Thanks,

    Harshit

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 676

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 633 Super User 2026 Season 1

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 624 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans