Al: Eventing in New Developer Environment

Created on 18 Jan 2017  路  11Comments  路  Source: microsoft/AL

Hello,

Is field level triggers and events available currently in new Developer environment. As in screen below we cannot see the particular field level trigger in Customer Table.
Neither it is available in Event Subscription function.
Anybody tried this and resolved it, please share. If not I think this can be treated as bug.

image

question

Most helpful comment

We have added a simplified way of subscribing to the validation events in the new compiler

tableextension 70050090 CustomerExtension extends Customer
{
    fields
    {
        modify(Name) // Modify the existing name field.
        {
            // Customizable properties can be changed here.
            CaptionML = ENU = 'My Changed Caption';

            trigger OnBeforeValidate();
            begin
                // Before validating customer name
            end;

            trigger OnAfterValidate();
            begin
                // After validation customer name
            end;
        }
    }
}

Same mechanism is supported for Fields and Actions on Pages in the PageExtension object.

All 11 comments

Do you want to see Field level triggers of LinkedVendorCode field?
then trigger should be added withing { }
Is it what you mean?

As @pmohanakrishna wrote, the trigger should be defined within the field definition block '{' '}'. In your case this means moving lines 11-14 to line 9

@pmohanakrishna and @StanislawStempin - Thanks for your replies and explanations.
Actually I was looking for Customer Table Existing Fields (ex - Name field) trigger. Can you please help me to identify the position in code where I can write and find the triggers like OnBeforeValidateEvent(CurrFieldNo) and OnAfterValidateEvent(CurrFieldNo) etc. of particular tables like Customer Table in my case?

We need to use codeunits to write subscribers
it should be like
[EventSubscriber(ObjectType::Table, 18, 'OnBeforeValidateEvent', 'Name',true,true)]
[EventSubscriber(ObjectType::Table, 18, 'OnAfterValidateEvent', 'Name',true,true)]

Use [EventSusbscriber in your image. or teventsub snippet.

We have added a simplified way of subscribing to the validation events in the new compiler

tableextension 70050090 CustomerExtension extends Customer
{
    fields
    {
        modify(Name) // Modify the existing name field.
        {
            // Customizable properties can be changed here.
            CaptionML = ENU = 'My Changed Caption';

            trigger OnBeforeValidate();
            begin
                // Before validating customer name
            end;

            trigger OnAfterValidate();
            begin
                // After validation customer name
            end;
        }
    }
}

Same mechanism is supported for Fields and Actions on Pages in the PageExtension object.

Looks nice, but I'd rather call it "OnModify". That would at least give you a much clearer picture on what is going on (imho). Just details though ;-)

But it seems intellisense is not able to offer modify first time in new object and fields names in modify?
Let me know if you didnt get it.

Hm, sorry, I didn't read it carefully enough.
Looks like a very different approach.. .

Pls ignore my comment and I'll try to understand it first ;-)

@pmohanakrishna The are still no keyword intellisense in the extension objects and don't have the field intellisense for the field modify() yet.

We do however already have intellisense for Field and Action lookup on pageextensions.

On, get it now :-) (I think). I didn't like the approach..
I have never been a fan of changing properties.
What happens when two apps change the same caption?

This is extension V1 functionality. Only a small subset of properties can be modified, the rest will cause compiler errors.

The conflict resolution is handled on the server. The rules are the same as for V1 extensions. At some point you will be able to personalize the caption, and thus overwriting any changes made to captions by extensions.

The is a long list of properties that can't be modified, only the ones deemed "safe" can.

For reference a list of the non-modifiable properties can be found here.

https://msdn.microsoft.com/en-us/dynamics-nav/extension-packages-capability-support-matrix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RonKoppelaar picture RonKoppelaar  路  3Comments

worldofthenavcraft picture worldofthenavcraft  路  3Comments

JavierFuentes picture JavierFuentes  路  3Comments

malue19 picture malue19  路  3Comments

ghost picture ghost  路  3Comments