web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

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

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

(0) ShareShare
ReportReport
Posted on by
how to create image field for adding a image of a person for our custom table without using Employee picture
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    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
  • Suggested answer
    YUN ZHU Profile Picture
    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
  • Aarthi Madhavan Profile Picture
    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
    Kamal Khakhkhar Profile Picture
    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
  • Govinda Kumar Profile Picture
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans