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
0
Answers
{
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
'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'
[EventSubscriber(ObjectType::Table, Database::"Item Category", OnBeforeInsertEvent, '', false, false)]
local procedure ItemCatOnBeforInsert(var Rec: Record "Item Category"; RunTrigger: Boolean)
begin
ItemCatValidateParentCat(Rec);
end;
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 regards
[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;