Skip to main content

Notifications

Announcements

No record found.

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

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

    I think you are confusing it with DateTime. Or what you are looking for is systemdateget

    community.dynamics.com/.../difference-between-today-and-systemdateget-methods

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

    Thanks..

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 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

    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,156 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

    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
    ergun sahin Profile Picture
    8,816 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

    Iam unable to paste the code here..

  • Martin Dráb Profile Picture
    231,923 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

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

    IMG_5F00_20220208_5F00_133605.jpg

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,202 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans