Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

JavaScript error when creation a new case

(0) ShareShare
ReportReport
Posted on by 75

I am getting an error on the onload of a form 

My function:

function BuildChangeNumber()
{

var currentDate = new Date();
var currentDay = currentDate.getUTCDate();
var currentMonth = currentDate.getUTCMonth();
var currentHour = currentDate.getUTCHours();
var currentMinute = currentDate.getUTCMinutes();
var currentSecond = currentDate.getUTCSeconds();
var tempDate = currentDate.getUTCFullYear()

alert(tempDate);
alert(currentDay);
return tempDate;
}

The on the control I add:

pastedimage1642517549167v1.png

pastedimage1642517571479v2.png

the error:

pastedimage1642517598464v3.png

any help is greatly appreciated.

dynamics 365 version 9.1 on-premise

Thanks

Nick

  • Verified answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: JavaScript error when creation a new case

    Hello,

    Please try below code which is working on my instance -

    function BuildChangeNumber()

    {

    var currentDate = new Date();

    var currentDay = currentDate.getUTCDate();

    var currentMonth = currentDate.getUTCMonth();

    var currentHour = currentDate.getUTCHours();

    var currentMinute = currentDate.getUTCMinutes();

    var currentSecond = currentDate.getUTCSeconds();

    var tempDate = currentDate.getUTCFullYear();

    alert(tempDate);

    alert(currentDay);

    //return tempDate;

    }

    there was one semicolon missing in your code and I have commented return statement which is not required.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: JavaScript error when creation a new case

    Hello,

    In your handler properties change BuildChangeNumber() to BuildChangeNumber, save and publish.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans