AL icon indicating copy to clipboard operation
AL copied to clipboard

Problem to fire OnInsert Table trigger on new record ListPart

Open geraldbeaulieu877 opened this issue 8 years ago • 8 comments

On List part page, after completed the PK record data, the OnInsertRecord is fired. But the OnInsert Table is not fired. I need to insert the INSERT(true);

trigger OnInsertRecord(BelowxRec : Boolean) : Boolean; begin INSERT(true); //forced OnInsert Trigger manually end;

geraldbeaulieu877 avatar Dec 27 '17 15:12 geraldbeaulieu877

Hi @geraldbeaulieu877 ! We will look into this and see if it is a bug or just expected behavior.

atoader avatar Dec 28 '17 08:12 atoader

This issue come when the trigger OnInsertRecord(BelowxRec : Boolean) : Boolean; is include in my page.

geraldbeaulieu877 avatar Dec 30 '17 19:12 geraldbeaulieu877

Can you provide are more complete repro/sample? Does this work when developed in C/SIDE?

esbenk avatar Jan 02 '18 07:01 esbenk

Have you tried exit(true) after the insert?

Avanti05 avatar Jan 02 '18 08:01 Avanti05

Of course it's work well in C/SIDE. I converted my c/side code to al and i have this issue. So if I remove the OnInsertRecord Trigger from al, the code work well.

geraldbeaulieu877 avatar Jan 02 '18 13:01 geraldbeaulieu877

I couldn't deduct that from the small code snippet. The reason for asking is whether this is a change in the generated code or a platform issue. It helps us to find the problem faster.

I will investigate if the generated code has changed for OnInsertRecord trigger.

esbenk avatar Jan 02 '18 13:01 esbenk

Hi @geraldbeaulieu877 and apologies for a delayed reply.

Could you please confirm if this is still an issue? If so, could you please provide:

  • Version of the server and AL extension you are using
  • Simple repro showing the problem

To help with the repro, I have tried the following extension code. A list page contains a list part with a repeater. When inserting an record in the list part, both OnInsertRecord and OnInsert are called. Does this repro work the same on your environment? If not, could you please modify the code to demonstrate the problem?

table 50100 CustomerHobby
{
    fields
    {
        field(1; Hobby; Text[250])
        {
        }
    }

    keys
    {
        key(PK; Hobby)
        {
            Clustered = true;
        }
    }

    trigger OnInsert()
    begin
        Message('Table OnInsert');
    end;
}

page 50101 CustomerHobbyListPart
{
    PageType = ListPart;
    SourceTable = CustomerHobby;

    layout
    {
        area(content)
        {
            group(GroupName)
            {
                repeater (ListPartRepeater)
                {
                    field(Hobby; Hobby) {}
                }
            }
        }
    }

    trigger OnInsertRecord(BelowxRec: Boolean): Boolean
    begin
        Message('OnInsertRecord');
    end;
}

page 50100 CustomerList2
{
    PageType = List;
    SourceTable = Customer;

    layout
    {
        area(Content)
        {
            part(HobbyList; CustomerHobbyListPart)
            {
            }
        }
    }
}

defr0std avatar Apr 16 '18 12:04 defr0std

If you are still having this issue, then please open a new issue.

thpeder avatar May 09 '18 08:05 thpeder