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 :
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
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

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

  • Verified answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    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/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 62 Most Valuable Professional

#2
11manish Profile Picture

11manish 23 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 10

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans