AL Triggers are not working in VSCODE.

new to AL and not sure if this is the right place to post but,
page 50110 DataTypeCard
{
PageType = Card;
ApplicationArea = All;
UsageCategory = Documents;
Caption = 'Date Type Card';

layout
{
area(Content)
{
group(GroupName)
{

}
}
}

actions
{
area(Processing)
{
action(ActionName)
{
ApplicationArea = All;

trigger OnOpenPage()
var
myInt: Integer;
begin
Message('The value of %1 is %2', 'YesOrNo', YesOrNo);
Message('The value of %1 is %2', 'Amount', Amount);
Message('The value of %1 is %2', 'When Was It', "When Was It");
Message('The value of %1 is %2', 'What Time', "What Time");
Message('The value of %1 is %2', 'Description', Description);
Message('The value of %1 is %2', 'Code Number', "Code Number");
Message('The value of %1 is %2', 'Ch', Ch);
Message('The value of %1 is %2', 'Color', Color);
end;

trigger OnAction()
var
myInt: Integer;
begin

end;

}
}
}

var
LoopNo: Integer;
YesOrNo: Boolean;
Amount: Decimal;
"When Was It": Date;
"What Time Was IT": Time;
description: Text[30];
"Code Number": Code[10];
ch: Char;
color: Option Red,Orange,Yellow,Green,Blue,Violet;

It say OnOpenPage is not a valid trigger and i cant get any other trigger to come up in intellisense, as well as typing them manually continues to say they're not valid triggers.

here is the error.

"Documents\AL\ALProject2\Date Type Card.Page.al(27,25): error AL0162: 'OnOpenPage' is not a valid trigger"

Ive tried reinstalling the AL extension, renaming the file, and a few more things i can't remember, this makes 0 sense as these as this is a valid trigger and every other page extension trigger does not work. Please help before I jump out a window.

Best Answer

  • DenSterDenSter Member Posts: 8,284
    edited 2022-11-17 Answer ✓
    Sure triggers are working, it's just in the wrong place. You have it inside an action, page level triggers go outside all layout elements. Intellisense will tell you what is available from where your cursor is. Just type 'trigger' and then type 'on' and it should drop down a list of available triggers.

    here's what shows up as available outside layout elements:
    6msrw6xbn8cw.png

    This is what's available in an action
    wn36hr846s7y.png
    OnOpenPage is not a valid trigger in an action

Answers

  • DenSterDenSter Member Posts: 8,284
    edited 2022-11-17 Answer ✓
    Sure triggers are working, it's just in the wrong place. You have it inside an action, page level triggers go outside all layout elements. Intellisense will tell you what is available from where your cursor is. Just type 'trigger' and then type 'on' and it should drop down a list of available triggers.

    here's what shows up as available outside layout elements:
    6msrw6xbn8cw.png

    This is what's available in an action
    wn36hr846s7y.png
    OnOpenPage is not a valid trigger in an action
  • iHateCodingiHateCoding Member Posts: 3
    DenSter wrote: »
    Sure triggers are working, it's just in the wrong place. You have it inside an action, page level triggers go outside all layout elements. Intellisense will tell you what is available from where your cursor is. Just type 'trigger' and then type 'on' and it should drop down a list of available triggers.

    here's what shows up as available outside layout elements:
    6msrw6xbn8cw.png

    This is what's available in an action
    wn36hr846s7y.png
    OnOpenPage is not a valid trigger in an action

    Thank you so much, really appreciate the detailed response, doing this course from Microsoft and it's not exactly the best at teaching specifics, again really appreciate your help!

    https://learn.microsoft.com/en-us/training/modules/intro-basics-al-programming/9-exercise
  • DenSterDenSter Member Posts: 8,284
    edited 2022-11-17
    Try this one:


    There's a playlist with more than 20 hours of content


    The videos are out of order in the playlist, there's a part 1 and part 2 for doing development in AL. I don't know who the dude in the first video is, kind of annoying how someone else's face is on 20 hours of dev training that I recorded
  • iHateCodingiHateCoding Member Posts: 3
    Haha i can imagine, I will definitely take a look at these, and appreciate the help!
Sign In or Register to comment.