Options

if boolean of a field is set to true then Editable in another field should also be true

salgorayasalgoraya Member Posts: 1
edited 2023-07-19 in NAV Three Tier
Hi, can someone please help? on Business Central AL, I am trying to set a rule, where if a Field Property Editable is set to true then another field should be set to true, if it's set to false then the other field should also be set to false.

field (Record1Boolean)
{
Editable=true
}
field (Record2Date)
{
Editable=Record2Variable
}

If Record1 = true then
Record2Variable := true

else
Record2Variable:= false.


this formula allows Record1 to be an editable boolean field. however i cant seem to keep Record2 to be editable, i need it to be if Record1 is set to true then Record2 should become an editable field.

please can anyone help. i really appreciate it

Best Answer

  • Options
    ExploreExplore Member Posts: 14
    Answer ✓
    In AL, you can use a trigger that is invoked whenever the value of Record1Boolean changes. Then within the trigger, you can update the Editable property of Record2Date based on the value of Record1Boolean.
    Example:
    tableextension 50100 MyTableExt extends Record2Table
    {
        trigger OnModify()
        var
            Record1Boolean@field: Boolean;
            Record2Date@field: Date;
        begin
            if Record1Boolean then
                Record2Date.Editable := true;
            else
                Record2Date.Editable := false;
            
            Modify();
        end;
    }
    

    Note: Make sure you replace "Record1Boolean" and "Record2Date" with the correct field names.

    When you implement this logic, whenever the value of Record1Boolean is changed, the Editable property of Record2Date will automatically update accordingly.

Answers

  • Options
    ExploreExplore Member Posts: 14
    Answer ✓
    In AL, you can use a trigger that is invoked whenever the value of Record1Boolean changes. Then within the trigger, you can update the Editable property of Record2Date based on the value of Record1Boolean.
    Example:
    tableextension 50100 MyTableExt extends Record2Table
    {
        trigger OnModify()
        var
            Record1Boolean@field: Boolean;
            Record2Date@field: Date;
        begin
            if Record1Boolean then
                Record2Date.Editable := true;
            else
                Record2Date.Editable := false;
            
            Modify();
        end;
    }
    

    Note: Make sure you replace "Record1Boolean" and "Record2Date" with the correct field names.

    When you implement this logic, whenever the value of Record1Boolean is changed, the Editable property of Record2Date will automatically update accordingly.
  • Options
    krikikriki Member, Moderator Posts: 9,089
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.