How to Disable table trigger in Business Central with AL extension

ChowdaryK
Member Posts: 16
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
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
0
Answers
-
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 validate0
-
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 coding0 -
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'0 -
help me how to disable this trigger //
[EventSubscriber(ObjectType::Table, Database::"Item Category", OnBeforeInsertEvent, '', false, false)]
local procedure ItemCatOnBeforInsert(var Rec: Record "Item Category"; RunTrigger: Boolean)
begin
ItemCatValidateParentCat(Rec);
end;0 -
Question is why do you want to disable the trigger for what is the end goal? A context will be helpful in giving a better solution.United Kingdom0
-
Dear Developer101 ,
I am encountering an issue with the Parent Category value while working with LS Retail. Previously, the category structure was functioning correctly in a tree format. However, after installing the LS Retail application, I now receive the following error message:
"Parent Category value must be ''."
Could you please help me understand why this error is occurring? Additionally, I would appreciate guidance on how to properly implement an Item Category tree structure in LS Retail to avoid this issue.
Thank you for your assistance. I look forward to your response. I am also contacting LS retail too.
best regards0 -
This issue I have raised has been resolved. Thank you for understanding.
0 -
What was the solution?United Kingdom0
-
[EventSubscriber(ObjectType::Codeunit, Codeunit::"LSC Retail Item Extensions", OnBeforeItemCatValidateParentCat, '', false, false)]
local procedure OnBeforeValidateItemCategory(var ItemCat: Record "Item Category"; var ItemCatValidateParentCat_Handled: Boolean)
begin
ItemCatValidateParentCat_Handled := true; // Skip the standard validation logic
end;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions