Hi,
I'm new in programming in AL ( and programming in general )
I have created a page to save some value related to an item (TDS Card)
page 95121 "TDS Card" { PageType = Card; SourceTable = "TDS"; layout { area(content) { group("SPECIFICATION DU PRODUIT") { field("Ingrédients"; Rec."Ingrédients") { ApplicationArea = All; MultiLine = true; } field("Allergènes"; Rec."Allergènes") { ApplicationArea = All; } field("OGM"; Rec."OGM") { ApplicationArea = All; } field("Ionisation"; Rec."Ionisation") { ApplicationArea = All; } field("DLC"; Rec."DLC") { ApplicationArea = All; } field("Conservation"; Rec."Conservation") { ApplicationArea = All; MultiLine = true; } field("Utilisation/préparation"; Rec."Utilprép") { ApplicationArea = All; MultiLine = true; } field("Législation"; Rec."Législation") { ApplicationArea = All; } field("Remarques"; Rec."Remarques") { ApplicationArea = All; MultiLine = true; } } group("CARACTERISTIQUE ORGANOLEPTIQUE DU PRODUIT") { field("Article"; Rec."Article") { ApplicationArea = basic; trigger OnLookup(var Text: Text): Boolean var ItemRec: Record Item; begin ItemRec.Reset(); if Page.RunModal(Page::"Item List", ItemRec) = action::LookupOK then Rec.Article := ItemRec."No."; end; } field("Odeur"; Rec."Odeur") { ApplicationArea = All; } field("Couleur"; Rec."Couleur") { ApplicationArea = All; } field("Saveur"; Rec."Saveur") { ApplicationArea = All; } } } } }
The page is working fine but i want to link the card directly from my item card
So i would like to create an option called "TDS" on main item card page that will open (or create if not exist) the new card (page 95121) and directly past the value N° "F00002" in this example to the field "Article"
In my table the field "Article" is the PK
Thanks a lot for your help.
Phil the newbie ;-)
Hi Neodep,
I'm happy to hear that your problem is solved.. thanks for letting us know.
Hi Kumar, thanks a lot for your help.
All is working as i want now.
Just need to fix and set some field and it will be perfect.
Why not add the table relation in field 1 "Article"
field(1; "Article"; Code[20]) { TableRelation = Item."No."; }
regards
table 95120 "TDS" { fields { field(1; "Article"; Code[20]) { } field(10; "Ingrédients"; Text[250]) { } field(11; "Allergènes"; Text[150]) { } field(12; "OGM"; Text[150]) { } field(13; "Ionisation"; Text[150]) { } field(14; "DLC"; Text[150]) { } field(15; "Conservation"; Text[250]) { } field(16; "Utilprép"; Text[250]) { } field(17; "Législation"; Text[250]) { } field(18; "Remarques"; Text[250]) { } field(30; "Odeur"; Text[50]) { } field(31; "Couleur"; Text[50]) { } field(32; "Saveur"; Text[50]) { } field(33; "RecID"; Integer) { AutoIncrement = true; } } keys { key(PK; "Article","RecID") { } } }
Here is the code of the table
table 95120 "TDS" { fields { field(1; "Article"; Code[20]) { } field(10; "Ingrédients"; Text[250]) { } field(11; "Allergènes"; Text[150]) { } field(12; "OGM"; Text[150]) { } field(13; "Ionisation"; Text[150]) { } field(14; "DLC"; Text[150]) { } field(15; "Conservation"; Text[250]) { } field(16; "Utilprép"; Text[250]) { } field(17; "Législation"; Text[250]) { } field(18; "Remarques"; Text[250]) { } field(30; "Odeur"; Text[50]) { } field(31; "Couleur"; Text[50]) { } field(32; "Saveur"; Text[50]) { } } keys { key(PK; "Article") { } } }
For instance, the Primary Key is only the field "Article" in the table "TDS"
I use the same value from the Item card table "No."
I think i understand what you mean about 2 keys but i have absolutely no idea on what i can do this.
Hi Newdep,
I don't understand your question. Could you please send me the primary keys of your TDS table?
What I recommend is adding two primary keys to your TDS table, one is the Article with relation Item table of "No." and the second is RecNo, with a data type of integer and set to auto-increment. This should help with automatically populating the field 'Article' with the 'No.' field from the Item card, if the primary key in the TDS table does not exist yet.
regards
And this is the code i have updated to create the link in Item card page
pageextension 95122 MyExtensionItemCard extends "Item Card" { actions { addafter(AdjustInventory) { action(TDS) { Image = GetSourceDoc; ApplicationArea = All; Promoted = true; PromotedCategory = Process; PromotedIsBig = true; PromotedOnly = true; Caption = 'TDS Card Action'; RunObject = page "TDS card"; RunPageLink = Article = field("No."); } } } }
Hi Kumar,
I undesrtand more now.. thanks for the code.
Its working at 80% now.
The last problem is when i click on an item that dont have yet value associated in "TDS Card", it doesnt created automaticaly when i open from the new link that you just helped me to create and i need to click on + from the card page and put the value from the field "No." from the "Item Card".
Then i open again the "TDS Card" from the new menu then its working.
Do you think is there a possibility to populate automatically the field "Article" with the field No. from Item card if the PK in table "TDS card" dont exists yet ?
Thanks a lot for your help.
Hi Neodep,
you need to create an extension in the "Item card" page, here is some custom code you can use as a starting point, but be sure to modify it to meet your specific needs
pageextension 50100 MyExtensionItemCard extends "Item Card" { actions { addafter(AdjustInventory) { action(TDS) { Image = GetSourceDoc; ApplicationArea = All; Promoted = true; PromotedCategory = Process; PromotedIsBig = true; PromotedOnly = true; Caption = 'TDS Card Action'; RunObject = page "TDS card"; RunPageLink = Article = field(Article); } } } }
Remember to specify where you want to add your action in the page. In the above code, I have added it after the 'AdjustInventory'.
I also recommend you to update your page type to 'CardPart'
Regards
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156