Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

how to create image field for our custom table without using Employee picture

Posted on by 22
how to create image field for adding a image of a person for our custom table without using Employee picture
Categories:
  • Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    how to create image field for our custom table without using Employee picture
    Hi Aarthi Madhavan,
     
    You can simply add the picture field to your custom table. To upload and display the picture, I suggest creating an additional list part page, similar to what's available on the default customer page, and attaching that list part to your custom page.
     
    You can also include functions for taking pictures and importing them. Here's an example of how I added a picture in the purchase invoice, where it wasn't initially available out of the box... to create the list part that captures pictures from your camera, you can refer to the example..
     
    tableextension 80003 PurchaseHeaderExt extends "Purchase Header"
    {
        fields
        {
            field(50100; PurchInvoiceImage; Media)
            {
                Caption = 'Purchase Invoice Picture';
            }
        }
    }
    
    pageextension 80003 PurchaseInvoiceExt extends "Purchase Invoice"
    {
        layout
        {
            addbefore(IncomingDocAttachFactBox)
            {
                part(PurchaseInvoicePicture; PurchaseInvoicePicture)
                {
                    ApplicationArea = All;
                    SubPageLink = "Document Type" = field("Document Type"),
                                                    "No." = field("No.");
                }
            }
        }
    }
    
    page 80003 PurchaseInvoicePicture
    {
        Caption = 'Purchase Invoice Picture';
        PageType = CardPart;
        DeleteAllowed = false;
        InsertAllowed = false;
        LinksAllowed = false;
        UsageCategory = Administration;
        SourceTable = "Purchase Header";
    
        layout
        {
            area(Content)
            {
                field(PurchInvoiceImage; Rec.PurchInvoiceImage)
                {
                    ApplicationArea = All;
                    ShowCaption = false;
                    ToolTip = 'Specifies the picture of the purchase invoice.';
                }
            }
        }
        actions
        {
            area(processing)
            {
                action(TakePicture)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Take';
                    Image = Camera;
                    ToolTip = 'Activate the camera on the device.';
    
                    trigger OnAction()
                    begin
    
                        Rec.TestField(Rec."No.");
                        Camera.AddPicture(Rec, Rec.FieldNo(PurchInvoiceImage));
    
                    end;
                }
                action(DeletePicture)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Delete';
                    Enabled = DeleteExportEnabled;
                    Image = Delete;
                    ToolTip = 'Delete the record.';
    
                    trigger OnAction()
                    begin
                        Rec.TestField(Rec."No.");
    
                        if not Confirm(DeleteImageQst) then
                            exit;
    
                        Clear(Rec.PurchInvoiceImage);
                        Rec.Modify(true);
                    end;
                }
            }
        }
    
        trigger OnAfterGetCurrRecord()
        begin
            SetEditableOnPictureActions;
        end;
    
        var
            Camera: Codeunit Camera;
            DeleteImageQst: Label 'Are you sure you want to delete the picture?';
            DeleteExportEnabled: Boolean;
    
        local procedure SetEditableOnPictureActions()
        begin
            DeleteExportEnabled := Rec.PurchInvoiceImage.HasValue;
        end;
    }
     
    For importing pictures, you can find detailed information in Zhu's blog.

    Best Regards,
    Govinda Kumar
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    Kamal Khakhkhar 303 on at
    how to create image field for our custom table without using Employee picture
    Hii There,
     
    as per your question i added sample for your understanding. if you need to get more details YUN ZHU created a great blog for it. and even though you want to get more knowledge for it you can go through *page 785 "Customer Picture"* as it has whole code as per requirement. Even though you have query feel free to reach.
     
    Thank You.
    Kamal Khakhkhar
  • Aarthi Madhavan Profile Picture
    Aarthi Madhavan 22 on at
    how to create image field for our custom table without using Employee picture
    Hi Kamal Khakhkhar , but we can't import any image in this.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    how to create image field for our custom table without using Employee picture
    Below is an example of adding a picture other than the default on an Item. I hope it can give you some tips.
    How to add a picture to Item Category (Manage item picture by group) – Customization
     
     
    Thanks.
    ZHU
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    Kamal Khakhkhar 303 on at
    how to create image field for our custom table without using Employee picture
    Hii There,
    as per your question you can create by geting referance of customer table.
    here i providing sample code for your referance.
     
    table
     
    field(140; Image; Media)
    {
    Caption = 'Image';
    ExtendedDatatype = Person;
    }
     
    page
     
    field(Image; Rec.Image)
    {
    ApplicationArea = All;
    ShowCaption = false;
    ToolTip = 'Specifies the picture of the Employee, for example, a logo.';
    }
     
    you can use it as per your requirement.
     
    thank you.
    Kamal Khakhkhar

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans