Associate Notes to other records
Internal Notes has the possibility of extending to other elements of Business Central allowing to implement its notes functionality to other pages. In this example we will see how to add the Internal Notes functionality to the Products table to display the notes of a product when selecting it in a purchase offer document.
To begin with, it is needed that we add the new type to the enum IDPINO Source Type.
enumextension 50100 "Source Type" extends "IDPINO Source Type"
{
value(2; "Item")
{
Caption = 'Item';
}
}
Also, it is required to add to the table IDPINO Cust./Vend. Int. Note the relation with the new Source Type.
tableextension 50102 "Cust./Vend. Int. Note" extends "IDPINO Cust./Vend. Int. Note"
{
fields
{
modify("Source No.")
{
TableRelation = IF ("Source Type" = CONST(Item)) Item;
}
}
}
To control the appearance of notes. Both are called ShowInternalNotes but have a significant difference in usage. While the first one allows us to manage notes containing a notification parameter that needs to control IDs, the second one allows us to manage any other that does not require the use of notifications.
In this case we are going to call the function to display an alert for a product and display it in the sales quote document.
procedure ShowItemInternalNotes(SalesDocumentType: Enum "Sales Document Type"; ItemNo: Code[20]; ItemDescription: Text)
var
InternalNotes: Record "IDPINO Cust./Vend. Int. Note";
DocumentType: Enum "IDPINO Document Type";
begin
InternalNotes.SetRange("Source Type", InternalNotes."Source Type"::Item);
InternalNotes.SetRange("Source No.", ItemNo);
InternalNotes.SetRange("Note Type", InternalNotes."Note Type"::Alert);
case SalesDocumentType of
SalesDocumentType::"Quote":
begin
InternalNotes.SetRange("Sales Quote", true);
DocumentType := DocumentType::"Sales Quote";
end;
end;
if not InternalNotes.IsEmpty() then
InternalNotesHelper.ShowInternalNotes(InternalNotes, ItemDescription, DocumentType);
end;
In case we want to work with some kind of notification, it is necessary to specify it as the last parameter in the function call.
To display those notes when selecting a product in the sales quote document, we must extend the Sales Line page to call our function from the codeunit. It is of vital importance that when handling notifications, we assign individual IDs for each product separately.
tableextension 50100 "Sales Line" extends "Sales Line"
{
fields
{
modify("No.")
{
trigger OnAfterValidate()
var
InternalNotes: Record "IDPINO Cust./Vend. Int. Note";
InternalNotesHelper: Codeunit "IDPINO Internal Note Helper";
Notification: Notification;
DocumentType: Enum "IDPINO Document Type";
begin
InternalNotes.SetRange("Source Type", InternalNotes."Source Type"::Item);
InternalNotes.SetRange("Source No.", Rec."No.");
case Rec."Document Type" of
Rec."Document Type"::Quote:
begin
InternalNotes.SetRange("Sales Quote", true);
DocumentType := DocumentType::"Sales Quote";
end;
end;
//It is necessary to assign an ID to each product in order to display the notification correctly.
if not InternalNotes.IsEmpty() then begin
Notification.Id('86CFD062-D996-4B30-9C8A-01AD50CB9C90');
InternalNotesHelper.ShowInternalNotes(InternalNotes, 'Product Description', DocumentType, Notification);
end;
end;
}
}
}
Finally, we implement the action that will open the page IDPINO Cust/Vend Int. Nt. List page that will allow us to add and edit notes from the product sheet.
pageextension 50100 "Item Card" extends "Item Card"
{
actions
{
addlast("ItemActionGroup")
{
action("Internal Notes")
{
ApplicationArea = All;
Caption = 'Internal Notes';
Promoted = true;
PromotedCategory = Category4;
PromotedOnly = true;
Image = Alerts;
ToolTip = 'Configure notes that will be shown to the user when the item is selected for a sales document.';
RunObject = Page "IDPINO Cust/Vend Int. Nt. List";
RunPageLink = "Source Type" = FILTER(Item),
"Source No." = FIELD("No.");
}
}
}
}