Hi,

 

I have a Freedom UI list where I can take a few actions after the user has selected one or more rows. The actions run as expected, but the records are kept selected after the actions run and the user has to manually clear the selection. What do I need to add to the custom code to clear the selection? 

Thanks,
Jose 

File attachments
Like 1

Like

7 comments
Best reply

Jose Hernandez,

 

You need to try

 

request.$context.GridDetail_tviz7gf_SelectionState = null
 

null is needed to remove the selection, but also change GridDetail_tviz7gf to your list attribute.

Hello,

Could you describe exactly what your custom logic performs for better understanding?

Malika,

 

It depends on the action. The Unlock one just clears the locked by field for the selected cases. The print generates letters and sends them to our print vendor for each case selected. Finally, the Assign one opens a window where the user can select the person to assign the cases to. Each one is calling the code below with the proper parameters.

I just need to know what I need to add to that code to clear the selection after the code that runs the business process.

 

Thanks,

Jose

        processSelectedRows: async function(request, processName, message, next) {
            var selectedRecords = await this.getSelectedRows(request.$context);
            var count = selectedRecords.count;
            var date = new Date();
            var hours = date.getHours();
            var minutes = date.getMinutes();
            var ampm = hours >= 12 ? 'PM' : 'AM';
            hours = hours > 12 ? hours - 12 : hours;
            var timeString = hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0') + " " + ampm;
            message = message + " on " + timeString + " for " +  count + " selected records.";
            request.$context.executeRequest({
                type: "crt.NotificationRequest",
                message:message
            });
            const handlerChain = sdk.HandlerChainService.instance;
            result = await handlerChain.process({
                type: 'crt.RunBusinessProcessRequest',
                processName: processName,
                processRunType: "RegardlessOfThePage",
                processParameters: {
                    "SelectedRecords": selectedRecords.selected
                },
                $context: request.$context
            });
            if (!result.success)  {
                var errorMsg = Ext.String.format(resources.localizableStrings.UnableToProcessSelectedRows, processName, result.errorInfo?.message);
                request.$context.executeRequest({
                    type: "crt.NotificationRequest",
                    message: errorMsg
                });                        
            }
            /* Call the next handler if it exists and return its result. */
            return next?.handle(request);
        }

I've not tried clearing the selections, but it might work to do this after you execute the process: 

request.$context.DataTable_SelectionState.selected = [];

Or it could be that you'll set SelectionState to null or {}?

Ryan

Ryan Farley,

Thanks Ryan. I tried that (and other variations like setting the type to 'clear') and the model gets cleared, but the GUI is not refreshed. In other worlds on the page the records are still showing as selected even though the model now has cleared the selection.

Jose Hernandez,

 

You need to try

 

request.$context.GridDetail_tviz7gf_SelectionState = null
 

null is needed to remove the selection, but also change GridDetail_tviz7gf to your list attribute.

Thanks Oleg. That worked. In my case I used  request.$context.DataTable_SelectionState = null; 

Viktoriia,

 

Hello,

 

It's 

 

request.$context.DataTable_SelectedRows
 

DataTable should be replaced with your list attribute name.

Show all comments