Microsoft Dynamics 365 Extensions Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Navigate to Settings | Solutions | Packt.
  2. Click on Web Resources and double-click on packt_common.js.
  3. Click on Text Edit and change the populateWithTodaysDate code to the following:
packtNs.common.populateWithTodaysDate =  function(attributeToMonitor, dateAttributeToChange) 
{
if (Xrm.Page.getAttribute(attributeToMonitor).getValue() !== null &&
Xrm.Page.getAttribute(dateAttributeToChange).getValue() === null)
{
Xrm.Page.getAttribute(dateAttributeToChange).setValue(
new Date());
}
}
  1. Add the following function:
packtNs.common.wireOnChangeEvents = 
function(eventAttributeTuples){
for (var i in eventAttributeTuples) {
Xrm.Page.getAttribute(eventAttributeTuples[i].attribute)
.addOnChange(eventAttributeTuples[i].function);
}
}
  1. Replace the loadEvent function with the following code:
packtNs.graduateForm.loadEvent = function(){
packtNs.common.wireOnChangeEvents([
{attribute: "packt_supervisor",
function:
packtNs.common.populateWithTodaysDate("packt_supervisor",
"packt_postgraduatestartdate")
}
]);
}
  1. Click on OK, followed by PUBLISH, and then close the dialog.