web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    236,394 Most Valuable Professional on at
    RE: Variable Timezone has not been declared

    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
    RE: Variable Timezone has not been declared

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

    IMG_5F00_20220208_5F00_133605.jpg

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: Variable Timezone has not been declared

    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
    RE: Variable Timezone has not been declared

    Iam unable to paste the code here..

  • Suggested answer
    ergun sahin Profile Picture
    8,824 Moderator on at
    RE: Variable Timezone has not been declared

    Don't use today as a variable name

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at
    RE: Variable Timezone has not been declared

    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,160 Moderator on at
    RE: Variable Timezone has not been declared

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

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at
    RE: Variable Timezone has not been declared

    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,160 Moderator on at
    RE: Variable Timezone has not been declared

    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
    RE: Variable Timezone has not been declared

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,004

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 857 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 548 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans