Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Auto-Fill value

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

On Job Planning Line page, corresponding to the Resource No, I have to auto-fill the 'Employee No' field corresponding to the particular resource.

I wrote the following code on OnValidate trigger of 'No.' field on Job Planning Line table, but it is not meeting the requirement.

How to modify it !

modify("No.")
        {
            trigger OnAfterValidate()
            var
                myInt: Integer;

            begin


                Rec_JobPlanningLine.SetRange("No.", Rec_Employee."Resource No.");
                if Rec_JobPlanningLine.FindFirst() then
                   
                    "Employee No" := Rec_Employee."No.";
          
            end;
  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Auto-Fill value

    Send the screenshot of the code you have written

  • RE: Auto-Fill value

    It is displaying the same Employee No. even if different resource is selected.

  • RE: Auto-Fill value

    Shouldn't it be JobPlanningLine.Get(No.) instead of Resouce.Get("No.") ?

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Auto-Fill value

    No, you don’t need any of those just the code I have added 

  • RE: Auto-Fill value

    What about the setrange statement written. Do I have to keep it as it is? 

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Auto-Fill value

    Your code doesn't make any sense since you want to get the value from the Resource table, you need to get the Resouce record based on the type and then populate it.

    Please check below

    If Type = Type:: Resource then being

      If Resouce.Get("No.") then

          "Employee No." := Resource."Employee No."

    end;

    Create Resource in the variables of type record for Resource table.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans