Skip to main content
Post a question

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

The name "FieldCaption" does not exist in the current context

Posted on 17 Feb 2023 17:43:39 by 185

I'm doing the Custom Functions Functions Exercise via Microsoft's Development learning path for manipulating data using code. HEre is the link if you want to visit the page...

Exercise - Custom functions - Training | Microsoft Learn

There is a direction to copy some code and paste in here, but that code creates an error that is difficult to understand. "The name FieldCaption/Credit Limit (LCY) does not exist in the current context."

pastedimage1676655492726v2.png

I have symbols downloaded, but there doesn't seem to be any direct info from Microsoft on how to solve this issue.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on 20 Feb 2023 at 01:19:40
    RE: The name "FieldCaption" does not exist in the current context

    Hi,

    You can try as per below

    CreditLimitCalculated := Rec.CalculateCreditLimit();

    if CreditLimitCalculated = Rec."Credit Limit (LCY)" then begin

    Message(CreditLimitUpToDateTxt);

    exit; end; if GuiAllowed() then

    if not Confirm(AreYouSureQst, false, Rec.FieldCaption("Credit Limit (LCY)"),CreditLimitCalculated) then exit;

    CreditLimitActual := CreditLimitCalculated;

    Rec.UpdateCreditLimit(CreditLimitActual);

    if CreditLimitActual <> CreditLimitCalculated then

    Message(CreditLimitROundedTxt, CreditLimitActual);

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on 20 Feb 2023 at 00:59:22
    RE: The name "FieldCaption" does not exist in the current context

    Hi, just adding some info.

    If this code is from MS Learn, maybe they forgot to update the program.

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-deprecating-with-statements-overview

    Thanks

    ZHU

  • Suggested answer
    tonyab Profile Picture
    tonyab 55 on 17 Feb 2023 at 22:03:38
    RE: The name "FieldCaption" does not exist in the current context

    Try doing Rec.FieldCaption("Credit Limit (LCY)")
    You need to have the table in front of the FieldCaption (which in this case would be the Rec variable to indicate the record you are working with). 

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans