Hello everyone!
I'm stuck on this issue .
I have a case with a subgrid with service activities. Each Service Activitiy is considered a visit on my scenario. Whenever a Service Activity is completed i want to decrease by one a field on my form called Remainining Number of Visits
Here is the code i'm using :
function DecrementNumberOfVisits() { var packageGrid = Xrm.Page.getControl("ServiceActivities").getGrid(); var packageRows = packageGrid.getRows(); var rowCount = packageRows.getLength(); var remainingVisits = Xrm.Page.getAttribute("ral_remainingnumberofvisits").getValue(); if (rowCount != 0) { for (var i = 0; i < rowCount; i++) { var rowEntity = packageRows.get(i).getData().getEntity(); var listStatus = rowEntity.getAttributes().get("statuscode").getValue(); if (listStatus == "Closed") { remainingVisitsts = remainingVisits - 1; } Xrm.Page.getAttribute("ral_remainingnumberofvisits").setValue(remainingVisits); Xrm.Page.getAttribute("ral_remainingnumberofvisits").setSubmitMode("always"); } } }
Whenever i try to run this code i get this message :
TypeError: Cannot read property 'getValue' of null at DecrementNumberOfVisits
Can anyone help me why this is happening ? I tried to use another field other than statuscode and still doesn't work. I also tried to use getText and i again get the same message.
*This post is locked for comments