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
    Bipin D365 28,961 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
    a33ik 84,325 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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans