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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Make link attachement mandatory

(0) ShareShare
ReportReport
Posted on by 335

Hi All,

I have a requirement where are i want to make link attachement mandatory under "Attachments" on item card page.

I tried it with show mandatory but it gives error ,the property "ShowMandatory" can't  be used in this context"

pageextension 50115 "Attachment" extends  "Document Attachment Factbox"
{
    actions
    {
        modify(Attachments)
        {
          
            ShowMandatory = true;
        }
    }
    
}
I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    Perhaps using the onclosepage trigger is a good idea. You can check if the item record has an attachment or not. When it doesn’t show an error.

  • Rupali  Profile Picture
    335 on at

    Can you please help me with the code?

  • Suggested answer
    JAngle Profile Picture
    133 on at

    Something like this:

    DocAtt.Reset();

    DocAtt.SetRange("Table ID", 27); DocAtt.SetRange("Document Type", DocAtt."Document Type"::Quote);  DocAtt.SetRange("No.", rec."No.");

       if not DocAtt.FindFirst()then Error(NoDocumentAttachmentsErr);

     end;

    Create variables for DocAtt as Document Attachment table. The error line can be a label or just hard code a text line.

  • Rupali  Profile Picture
    335 on at

    Josh,

    Thanks alot!!

    I was able to do that for Documents under Attachment but I want to do that under Links section .I dont know why it does not let me put Links as a page for page extension

    When I inspected it shows Links(SystemPart) as a page but it doesn't let me extend this page through AL.

    Here is my code:

    pageextension 50117 "Attachments" extends "Document Attachment Factbox

    {

       layout

       {

           // Add changes to page layout here

           modify(Documents)

           {   //BlankZero = true;

               ShowMandatory = true;

           }

       }

       var

           NoDocumentAttachmentsErr: Label 'Please attach Document';

       trigger OnClosePage()

       var

           DocAtt: Record "Document Attachment";

       begin

           DocAtt.Reset();

           DocAtt.SetRange("Table ID", 2000000068);

           DocAtt.SetRange("Document Type", DocAtt."Document Type"::Quote);

           //DocAtt.SetRange("No.",rec."No.");

           if not DocAtt.FindFirst() then

               Error(NoDocumentAttachmentsErr);

       end;

    }

  • Suggested answer
    JAngle Profile Picture
    133 on at

    This is not where I would put the code. This will make all pages that access the document attachment have to abide by the logic. The page to extend would be the Item Card as that relates to your main scenario.

    The record link table is a system one so you cannot access it directly with code. I would suggest using a built in function item.HasLinks. This returns a boolean, so you could do If item.HasLinks then exit else error('Item needs links');

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans