function countCompletedReviews(executionContext) { var formContext = executionContext.getFormContext(); // Get the subgrid control by its name var subgrid = formContext.getControl("Subgrid_new_1"); // Check if the subgrid is loaded if (subgrid && subgrid.getGrid) { // Get the rows of the subgrid var rows = subgrid.getGrid().getRows(); // Initialize a variable to store the total count var total = 0; // Loop through each row for (var index = 0; index < rows.getLength(); index++) { // Get the data of the row var data = rows.get(index).getData(); // Get the entity of the row var entity = data.getEntity(); // Get the status attribute of the entity var status = entity.attributes.get("statuscode"); // Check if the attribute value is completed , 565930001 is value of completed status if (status && status.getValue() == 565930001) { // Add the number to the total total = total + 1; } } // populate filed formContext.getAttribute("cre80_completedreview").setValue(total); } }
function CompletedObligationReviewCount (executionContext) { var formContext = executionContext.getFormContext(); // Get the subgrid control by its name var subgrid = formContext.getControl("Obligation_Review_Record_Subgrid"); // Check if the subgrid is loaded if (subgrid && subgrid.getGrid) { // Get the rows of the subgrid var rows = subgrid.getGrid().getRows(); var completedRecordsFilter = "<filter type='and'><condition attribute='sksysdev_reviewstatus' operator='eq' value='2'/></filter>"; formContext.getControl(subgrid).getGrid().addCustomFilter(completedRecordsFilter, entity); // Initialize a variable to store the total completed record counts var totalcount = 0; // Loop through each row for(var index=0; index<rows.getLength(); index++) // Get the data of the row var data = rows.get(index).getData(); // Get the entity of the row var entity = data.getEntity(); // Get the review status attribute of the entity var statuscounts = entity.attributes.get("sksysdev_reviewstatus"); // Check if the attribute has a value if (statuscounts && statuscounts.getValue()) { // Add the value to the total totalcount += statuscounts.getValue(); } }; // Display the total in the Obligation Review Record Count field (under Case) formContext.getAttribute("sksysdev_obligationreviewrecordcount").setValue(totalcount); }
function CompletedRecordCount (executionContext) { var formContext = executionContext.getFormContext(); var completedRecordsFilter = "<filter type='and'><condition attribute='sksysdev_reviewstatus' operator='eq' value='2'/></filter>"; try { setTimeout(function () { if (formContext != null && formContext != undefined && formContext.getControl("Obligation_Review_Record_Subgrid") != null && formContext.getControl("Obligation_Review_Record_Subgrid") != undefined) { var totalcount = formContext.getControl("Obligation_Review_Record_Subgrid").getGrid().addCustomFilter(completedRecordsFilter, "sksysdev_obligationreview").getTotalRecordCount(); formContext.getAttribute("sksysdev_obligationreviewrecordcount").setValue(totalcount); } }, 3500); // You can increase some more time if its not works then } catch (e) { Xrm.Utility.alertDialog(functionName + "Error: " + e.message || e.description); } }
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Andrés Arias as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 258
Daniyal Khaleel 178
Tom_Gioielli 75 Super User 2025 Season 2