Issue with Role-Based Lookup Filtering in Editable Detail Grid

Hi Creatio Community,

I'm currently working with an editable detail grid, and I need to filter a lookup column (UsrPort) based on the connected user's roles ("Stay SPOC TC", "Stay SPOC Casablanca", "Stay SPOC Jorf Lasfar", "Stay SPOC Laayoune", and "Stay SPOC Safi").

I've tried several approaches including:

  • Defining lookupListConfig with prepareList binding (works fine on regular pages but does not trigger in editable grids).



    Here's the latest implementation I've tested:
     

generateActiveRowControlsConfig: function(id, columnsConfig, rowConfig) {
    this.mixins.ConfigurationGridUtilitiesV2.generateActiveRowControlsConfig.call(this, id, columnsConfig, rowConfig);
 
    var scope = this;
 
    Terrasoft.each(rowConfig, function(columnItem) {
        var columnKey = columnItem.key && columnItem.key[0];
        if (columnKey && columnKey.name === "UsrPort") {
            columnItem.controlConfig = columnItem.controlConfig || {};
            columnItem.controlConfig.lookupListConfig = columnItem.controlConfig.lookupListConfig || {};
            columnItem.controlConfig.lookupListConfig.filter = function() {
                var filters = Terrasoft.createFilterGroup();
 
                // Example of role checks
                var allowedPorts = [];
                if (scope.get("IsStaySpocCasa")) allowedPorts.push("CASABLANCA");
                if (scope.get("IsStaySpocJorf")) allowedPorts.push("JORF LASFAR");
                // Add similar checks for other roles
 
                if (allowedPorts.length > 0) {
                    filters.add("PortFilter", Terrasoft.createColumnInFilterWithParameters("Name", allowedPorts));
                } else {
                    filters.add("EmptyFilter", Terrasoft.createColumnFilterWithParameter(
                        Terrasoft.ComparisonType.EQUAL, "Id", Terrasoft.GUID_EMPTY));
                }
 
                return filters;
            };
        }
    }, this);
},

This configuration currently doesn't work and results in the error mentioned above.

Could someone help clarify the correct way to implement role-based filtering on lookup columns within editable detail grids? If anyone has successfully implemented this or faced a similar issue, your guidance would be greatly appreciated!

Thanks in advance for your help!

Best regards,

Like 0

Like

2 comments

For classic details, rules implemented on the page are also manifested in the list for the detail. I believe you can just implement the filtering for the lookup on the page for the detail, then it will work in the list as well. 

Thank you Ryan  for your answer!
Actually, my detail is an editable grid. I noticed that the page-level lookup filtering doesn't propagate into editable grids automatically. From my tests and observations, the editable grids seem to require explicit filtering logic within the generateActiveRowControlsConfig method instead.
Could you please confirm if this understanding is correct, and perhaps suggest any best practices or examples explicitly for editable grids?

Show all comments