web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • 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,983 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 57 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 34 Most Valuable Professional

#3
Scott Jackson UK Profile Picture

Scott Jackson UK 22

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans