Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How to create a link (action) from an item card to another card page and paste some value ?

(0) ShareShare
ReportReport
Posted on by 20

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

pastedimage1681286919074v1.png

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  ;-)

  • Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    Hi Neodep,

    I'm happy to hear that your problem is solved.. thanks for letting us know.

  • Neodep Profile Picture
    Neodep 20 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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.

  • Verified answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    Why not add the table relation in field 1 "Article"

    field(1; "Article"; Code[20]) { TableRelation = Item."No."; }

    regards

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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 how you can add it
    Regards

  • Neodep Profile Picture
    Neodep 20 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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") { }
    
        }
    }

  • Neodep Profile Picture
    Neodep 20 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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.

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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

  • Neodep Profile Picture
    Neodep 20 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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.");
                }
            }
        }
    }

  • Neodep Profile Picture
    Neodep 20 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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.

    pastedimage1681303661654v1.png

  • Verified answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to create a link (action) from an item card to another card page and paste some value ?

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans