How to Disable table trigger in Business Central with AL extension

ChowdaryKChowdaryK Member Posts: 12
Hi,

I want to disable table trigger on item category table for Parent Category

field(2; "Parent Category"; Code[20])
{
Caption = 'Parent Category';
TableRelation = "Item Category";

trigger OnValidate()
var
ItemCategory: Record "Item Category";
ItemAttributeManagement: Codeunit "Item Attribute Management";
ParentCategory: Code[20];
begin
ParentCategory := "Parent Category";
while ItemCategory.Get(ParentCategory) do begin
if ItemCategory.Code = Code then
Error(CyclicInheritanceErr);
ParentCategory := ItemCategory."Parent Category";
end;
if "Parent Category" <> xRec."Parent Category" then
ItemAttributeManagement.UpdateCategoryAttributesAfterChangingParentCategory(Code, "Parent Category", xRec."Parent Category");
end;

Please help me

Answers

  • JJMcJJMc Member Posts: 61
    You can suscribe to the onbeforevalidate of the field, do whaever you want, then commit the changes, if there is any, and then error('') to stop the standard validate
  • ChowdaryKChowdaryK Member Posts: 12
    modify("Parent Category")
    {
    trigger OnBeforeValidate()
    begin
    "Parent Category":=rec."Parent Category";
    if rec.Parent<>'' then // custom field stored for parent category tempororly
    "Parent Category":=rec.Parent;
    end

    is this bypass on validate trigger.?

    Please help with code as I am not good in coding
  • ChowdaryKChowdaryK Member Posts: 12
    will you give me code on the subjected field.
    'You can subscribe to the onbeforevalidate of the field, do wherever you want, then commit the changes, if there is any, and then error('') to stop the standard validate'
Sign In or Register to comment.