Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Editable grid doesnt show the correct value after setValue()

Posted on by
Hi, 
 
I have an editable grid and would like to change the value in column /Weeks/ as soon as I adjust a date in column /CRD/ or /DDP/. 

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 means that the correct value is set via setValue, but it is not updated directly in the grid. It is only updated when I double-click on the field. That's crazy. 
Where could the error be? I have already tried different browsers, but the same problem everywhere: 
 
I use this code: 
 
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);                    }                }            }        );}
 
//
 
In the GIF you see that i have to Click on the field after update the date. 
 
If I update the form with Xrm.Page.getControl(/Subgrid_new_2/).refresh();, I get the correct value, but I don't think that can be the solution. 
Does anyone have an idea?
 
Thank you very much !
 
 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans