This also works the first time I change the date. As soon as I change the date a second time, the value no longer changes in column /Week/, but only when I click on the field.
this.calculateEvaluatedWeeksGrid = function (executionContext) { var formContext = executionContext.getFormContext(); var currentRowId = formContext.data.entity.getEntityReference().id.replace(/{|}/g, ''); var crd = formContext.getAttribute(fields.Crd).getValue(); var ddp = formContext.getAttribute(fields.Ddp).getValue(); Xrm.WebApi.retrieveRecord(entities.Lot, currentRowId, /?$select=_hoy_related_project_value&$expand=hoy_related_project($select=_hoy_sourcing_season_value;$expand=hoy_sourcing_season($select=hoy_logistic_2_0_from,hoy_logistic_2_0_to))/).then( function success(result) { var from = result.hoy_related_project.hoy_sourcing_season.hoy_logistic_2_0_from; var to = result.hoy_related_project.hoy_sourcing_season.hoy_logistic_2_0_to; if (crd !== null && ddp !== null) { diff = Math.round((ddp - crd) / (7 * 24 * 60 * 60 * 1000)); //evaluatedWeeks = formContext.getAttribute(fields.EvaluatedWeeks).setValue(diff) evaluatedWeeks = formContext.getAttribute(fields.EvaluatedWeeks).setValue(diff); if (diff >= from && diff <= to) { formContext.getAttribute(fields.EvaluatedWeeks).setValue(calculateStatus.Erfuellt); } else { formContext.getAttribute(fields.EvaluatedWeeks).setValue(calculateStatus.Nicht); } } } );}
Does anyone have an idea?