Hi all,
Quick question. I've created a ribbon button available in the grid view, only appearing when a user selects one or more cases. This function allows a person to resolve all selected cases in the grid. Basically what I'm doing is that I'm passing through the ID of the selected cases by using the SelectedControlSelectedItemIds parameter which you can pass. I then use those IDs and a few other static variables to loop through the array of case IDs which then calls another function which uses the /api/data/v9.2/CloseIncident web API method.
This works fine. I'm now after a way to put in some conditions on what they can and cannot resolve based on certain fields on the case. This is fine with a form button as you can get the formContext which then allows you to get the values of fields on the form but I'm looking at the Grid Context which you can get from the SelectedControl parameter which you can pass via the ribbon. It's just I'm having trouble finding a way of retrieving certain attribute values from selected records in a grid to use as a check for whether selected case can be resolved. Can someone point me in the right direction on getting certain attribute values from selected records in a grid?
Would I need to create another function that uses the web API to loop through the selected record IDs and use the get value API method or is there a way to get attributes via the grid context? Does the field need to be visible on the grid? Below is the code snippet which works well for resolving selected cases from a grid.
async function ribbonGridResolve(SelectedControlSelectedItemIds, SelectedControl) { var subject = 'static subject' var billableHours = 60; var resolutionDescription = 'static description'; var resolutionCode = 5; // Not sure whether I can use the gridContext to retrieve attributes from selected values var gridContext = SelectedControl; var i; Xrm.Utility.showProgressIndicator('Resolving'); for (i = 0; i < SelectedControlSelectedItemIds.length; i ) { var caseId = SelectedControlSelectedItemIds[i] var actualIndex = i 1; // This calls a separate function I created that specifically calls the web API closeincident method await closeCase(subject, caseId, billableHours, resolutionDescription, resolutionCode, SelectedControlSelectedItemIds.length, actualIndex); } Xrm.Utility.closeProgressIndicator(); }
I want to put in some additional checks within the for loop based on certain field values in each case but not sure how to retrieve attribute values in the grid and specifically for selected grid items.