web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Variable Timezone has not been declared

(0) ShareShare
ReportReport
Posted on by 45

Please guide me iam getting below error in ax 2012...

How can I resolve this error

16442976342396588639540111149007.jpg

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,953 Most Valuable Professional on at

    In AX 2012, you can't declare variables inside 'case' block. You need to declare the variable on the top of the method.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Declare the variable at top of the method..again same error showing.

    IMG_5F00_20220208_5F00_133605.jpg

  • Martin Dráb Profile Picture
    238,953 Most Valuable Professional on at

    Please give us your code as text, so we can see it in full and compile it ourselves.

    Use Insert > Code (in the rich formatting view) to paste it here.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Iam unable to paste the code here..

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    Don't use today as a variable name

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Public boolean Validate field(FieldId _fieldIdToCheck)

    {

    Timezone   clientTimeZone;

    TransDate    today;(Getting error in this line : variable TransDate has not been declared)

    boolean IsValid;

    Is valid = super(_fieldIdToCheck);

    switch (_fieldIdToCheck)

    {

    case FieldNum(FMS_ResortTable, Acquisition Date):

    clientTimeZone = DateTimeUtil::getClientMachineTimeZone();

    today = DateTimeUtil::getSystemDate(clientTimeZone);

    if(this.AcquisitionDate < today)

    {

    IsValid = CheckFailed ("FMS23");

    }

    break;

    }

    return IsValid;

    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    As others already pointed out, you can't use "today" as a variable name. 

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    I have changed the variable name and the error now showing in the below line

    getSystemDate(clientTimezone);error I am getting:GetSystemDate Is not a class method

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Well, there's not a method called DateTimeUtil::getSystemDate, so you will get an error.

    If you type DateTimeUtil:: the IntelliSense shows you what's available.

    If you need the current date, you can use systemDateGet() function.

    Generally I'd like to suggest that you participate in some development basics course, so that you'll learn to the basics of the x++ syntax, IntelliSense and other things.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Thanks..

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 531

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 257 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans