Hi everyone,
I need some help to show a specific value depending on the value from 4 boolean fields ( 401 to 404 )
Part of my table :
Hi everyone,
I need some help to show a specific value depending on the value from 4 boolean fields ( 401 to 404 )
Part of my table :
Many thanks Zhu, just tested now and its perfect !
Sorry I didn't understand the question at all before. Now I understand.
You can do something like below. You can define some functions to make it look more concise. In addition, for the convenience of testing, I only considered that when the page is modified, you can also add it to the trigger of the table.
page 50010 "Lab Book" { ApplicationArea = All; UsageCategory = Administration; Caption = 'Lab Book'; PageType = Card; SourceTable = "Lab Book"; layout { area(content) { group(General) { Caption = 'General'; field("No."; Rec."No.") { ToolTip = 'Specifies the value of the No. field.'; } field(Lait; Rec.Lait) { ToolTip = 'Specifies the value of the Lait field.'; trigger OnValidate() begin if Rec.Lait then if Contains = '' then Contains := Rec.FieldName(Lait) else Contains := Contains ' and ' Rec.FieldName(Lait); end; } field("Fruits coque"; Rec."Fruits coque") { ToolTip = 'Specifies the value of the Fruits coque field.'; } field("Céleri"; Rec."Céleri") { ToolTip = 'Specifies the value of the Céleri field.'; } field(So2; Rec.So2) { ToolTip = 'Specifies the value of the So2 field.'; } field(Allergen; Rec.Allergen) { ToolTip = 'Specifies the value of the Allergen field.'; MultiLine = true; } } } } var Contains: Text[100]; trigger OnModifyRecord(): Boolean begin if (not Rec.Lait) and (not Rec."Fruits coque") and (not Rec."Céleri") and (not Rec.So2) then begin Rec.Allergen := 'This product does not contain allergen'; end else begin Contains := ''; if Rec.Lait then Contains := Rec.FieldName(Lait); if Rec."Fruits coque" then if Contains = '' then Contains := Rec.FieldName("Fruits coque") else Contains := Contains ' and ' Rec.FieldName("Fruits coque"); if Rec."Céleri" then if Contains = '' then Contains := Rec.FieldName(Céleri) else Contains := Contains ' and ' Rec.FieldName(Céleri); if Rec.So2 then if Contains = '' then Contains := Rec.FieldName(So2) else Contains := Contains ' and ' Rec.FieldName(So2); Rec.Allergen := StrSubstNo('This product contains %1', Contains); end; end; }
Test Video:
[View:/cfs-file/__key/communityserver-discussions-components-files/758/Test04251650.mp4:1024:768
Hope this helps.
Thanks.
ZHU
Thanks Zhu for your help.
So i suppose that i need to create all combination in test trigger, there is no way to just create a var that concatenate the value when the field are "on"
btw : thanks for your website, its helped me a lot to create my dev.
Hi, Just a simple example. But I think your logic is not rigorous enough....
page 50010 "Lab Book" { ApplicationArea = All; UsageCategory = Administration; Caption = 'Lab Book'; PageType = Card; SourceTable = "Lab Book"; layout { area(content) { group(General) { Caption = 'General'; field("No."; Rec."No.") { ToolTip = 'Specifies the value of the No. field.'; } field(Lait; Rec.Lait) { ToolTip = 'Specifies the value of the Lait field.'; } field("Fruits coque"; Rec."Fruits coque") { ToolTip = 'Specifies the value of the Fruits coque field.'; } field("Céleri"; Rec."Céleri") { ToolTip = 'Specifies the value of the Céleri field.'; } field(So2; Rec.So2) { ToolTip = 'Specifies the value of the So2 field.'; } field(Allergen; Rec.Allergen) { ToolTip = 'Specifies the value of the Allergen field.'; } } } } trigger OnModifyRecord(): Boolean begin if (not Rec.Lait) and (not Rec."Fruits coque") and (not Rec."Céleri") and (not Rec.So2) then begin Rec.Allergen := 'This product does not contain allergen'; exit; end; if (Rec.Lait) and (Rec."Céleri") then begin Rec.Allergen := 'This product contains "Lait" and "Céleri'; exit; end; if Rec."Fruits coque" then begin Rec.Allergen := 'This product contains "Fruits coque"'; exit; end; end; }
Test video:
[View:/cfs-file/__key/communityserver-discussions-components-files/758/Demo04250931.mp4:1024:768
Hope this helps.
Thanks.
ZHU
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156