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 :
Microsoft Dynamics CRM (Archived)

Issue setting date field in CRM Dynamics 365 with setValue

(0) ShareShare
ReportReport
Posted on by

Using this script

//If the DSR namespace object is not defined, create it.
if (typeof (DSR) == "undefined")
{ DSR = {}; }
// Create Namespace container for functions in this library;
DSR.Main = {
    Form_onload: function () {
    },
    Form_onsave: function (context) {        
    },

// Hook this function to onchange of customerid
    Form_onchange: function () { // Notice difference between TAB and SHIFT+TAB, for onchange bug
        if (Xrm.Page.getAttribute("customerid") != null) {
  var tempvalue = Xrm.Page.getAttribute("customerid").getValue();
          if (tempvalue != null) {
  Xrm.Page.getAttribute("activeon").setValue(new Date());
          } else {
  Xrm.Page.getAttribute("activeon").setValue(null);
          }
        }
    }
};

... and hiding the "serviceaddress" field on the form (so "activeon" immediately follows "customerid"), the value in activeon WILL be set on putting in a customer and doing TAB (into the next field which now happens to be the date field), but if you leave the date field the value immediately goes away. It ONLY happens with date fields and only if it is the field you enter (so if you do Shift+TAB and move upwards into a different field than "activeon", you do not have the problem).

Is there a fix for this anywhere? Because losing dates in a form without noticing (it does so on close+save as well) is quite a problem, as we have a lot of forms where we set a date field depending on the activity done to the previous field.

We run CRM 365 without autosave.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    forgot to add.. example of problem was done using the "contract" entity.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans