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

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Manish Sharma blog / Using Standard Events &...

Using Standard Events & Subscriber in your Codeunit.

ManishS Profile Picture ManishS 6,578

In our recent upgrade from Dynamics NAV to D365BC we learnt a lot of things.

One was the events & subscriber.

Client required that they will have a single location for sales, which should not be selected by user and must be setup in such a way that when user creates sales order it should fill in from the default values.

So we build an extension where in system shall pick this from setup which was in inventory setup.

We extended the inventory table, and added a new field "Default Location", below extension.

6787.Invsetup-Extension.png

Next we extend the inventory setup page to show the field.

We needed to add it at last, so we added it after Internal Movement Nos.

5127.Invsetup-Extension-Page.png

Now we needed to write a Codeunit as eventsubscriber,

3718.Invsetup-Extension-CU.png

This is the syntax for using the eventsubscriber,
[EventSubscriber(ObjectType::Codeunit, Codeunit::, 'OnSomeEvent', 'ElementName', SkipOnMissingLicense, SkipOnMissingPermission)]
Here OnSomeEvent is important, Press Ctrl+Spacebar to get the events present in the object what you have selected.
This way you can write you customized code that you have written on standard codeunits.
If you are unware of which event to check for code,
you can have a look onto the OnPrem development environment and check the code to see if there are events already present for use.

Comments

*This post is locked for comments