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);
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal...
288,584
Super User
Martin Dráb
225,864
Super User
nmaenpaa
101,148