Auto-fill field value?

mysamzamysamza Member Posts: 66
I got a table;
table 50148 "Bank Securities"
{
    DataClassification = ToBeClassified;

    fields
    {
        field(50000; "Entry No"; Integer)
        {
            DataClassification = ToBeClassified;
        }
 
        field(50011; "Job No."; Code[20])
        {
            DataClassification = ToBeClassified;
            TableRelation = Job.No.;
        }
        field(50012; "Bill-to Customer No."; Code[20])
        {
            DataClassification = ToBeClassified;
            TableRelation = Job.Bill-to Customer No.;
        }

    }

    keys
    {
        key(PK; "Entry No", "Job No.")
        {
            Clustered = true;
        }
    }

    var
        myInt: Integer;

    trigger OnInsert()
    var
        recBankSec: Record "Bank Securities";
        EntryNo: Integer;
        recJob: Record Job;
    begin
        Clear(recBankSec);
        Clear(EntryNo);
        IF recBankSec.FindLast() then
            EntryNo := recBankSec."Entry No" + 1
        else
            EntryNo := 1;
        Rec."Entry No" := EntryNo;

        recJob.SetFilter("No.", rec."Job No.");
        IF recJob.FindFirst() then begin
            Rec."Bill-to Customer No." := recJob."Bill-to Customer No.";
        end;
    end;

}

and a Card page;
page 50149 "Bank Securities"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "Bank Securities";
    RefreshOnActivate = true;

    layout
    {
        area(Content)
        {
            group("Bank Security")
            {
                field("Job No."; "Job No.")
                {
                    ApplicationArea = All;
                }
                field("Bill-to Customer No."; "Bill-to Customer No.")
                {
                    ApplicationArea = All;
                    Editable = false;
            }
        }
    }

    actions
    {
        area(Processing)
        {
            /*   action(ActionName)
              {
                  ApplicationArea = All;

                  trigger OnAction()
                  begin

                  end;
              } */
        }
    }
}

42



}
}
}

actions
{
area(Processing)
{
/* action(ActionName)
{
ApplicationArea = All;

trigger OnAction()
begin

end;
} */
}
}
}




On the Card page, when I select a Job No. I get the Bill-to Customer No value filled in.

However, if I then change the Job No. the Bill-to Customer No. value does not change and remains the same.
Here is an example;

Job table has a record with No. and Bill-to Customer as DME, 50000 respectively.

On my card page, on my Job No. field, I select the above-mentioned record, and my Job No. field has value DME and Bill-to Customer field has value 50000.
So far so good.
I then change my mind to go to Job No. field to select the following record from the Job table which has a record with No. and Bill-to Customer as SME, 20000 respectively.

Now on my card page's Job No. field has value as SME however, Bill-to Customer is still 50000 and not 20000.

Best Answer

Answers

Sign In or Register to comment.