Specific to the user how to hide standard actions on details

Hi Community,

 

I need to hide the Export to Excel option for Details present on the record edit page for all users except for Specific users like Supervisor.

 

However I have asked this question earlier and Ryan has replied to that and that works fine as well. But now the situation is that this is to be done for specific users.

https://community.creatio.com/questions/how-hide-standard-actions-details-record-edit-page

 

Please tell me how to achieve this functionality

 

Many Thanks!

Akshit.

Like 0

Like

2 comments

Hello Akshit,

To hide for specific users only, you can add something like the following to the detail schema's methods:

getExportToExcelMenuVisibility: function() {
    // first make sure it's not already hidden due to operation permissions
    var baseVisible = this.callParent(arguments);
    if (!baseVisible) {
        return false;
    }
 
    // now you can return true or false to show/hide for current user
    return true; // or return false to hide for the current user
},
getDataImportMenuItemVisible: function() {
    // first make sure it's not already hidden due to operation permissions
    var baseVisible = this.mixins.FileImportMixin.getDataImportMenuItemVisible.apply(this, arguments);
    if (!baseVisible) {
        return false;
    }
 
    // now you can return true or false to show/hide for current user
    return true; // or return false to hide for the current user
}

However, note, only go this route with code if you need to limit this capability in this specific detail only. If you're wanting to remove this from everywhere in the app, then using the operation permission as Julio mentioned in your other post is the right approach.

Ryan

Hello Akshit,

 

I've achieved the result needed using the following scenario:

 

1) Create an operation permission with "CanExportDataOnCustomDetail" code:

Here we will specify the list of users or roles who will be able to export data from our custom detail.

 

2) Create a detail in the contacts section with the following schema of the detail (not the detail page, but detail itself):

define("UsrSchemafd43c0a7Detail", ["RightUtilities"], function(RightUtilities) {
	return {
		entitySchemaName: "UsrContactCaseDetailV2",
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
      	attributes:{
          "CanExportDataOnCustomDetailAtt":{
            dataValueType: Terrasoft.DataValueType.BOOLEAN,
            type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
            value: false
          }
        },
		methods: {
          init: function() {
                this.callParent(arguments);
                this.checkOperationPermission();
            },
          checkOperationPermission: function () {
            var operationsToRequest = [];
            debugger;
            operationsToRequest.push("CanExportDataOnCustomDetail");
            RightUtilities.checkCanExecuteOperations(operationsToRequest, function(result) {
                    if (result) {
                      	this.set("CanExportDataOnCustomDetailAtt", result.CanExportDataOnCustomDetail);
                      	console.log("result.CanExportDataOnCustomDetail: "+result.CanExportDataOnCustomDetail);
                    }
                }, this);
          },
          getExportToExcelMenuVisibility: function (){
            if (this.get("CanExportDataOnCustomDetailAtt")===true){
              return true;
            } else {
              return false;
            }
          }
        }
	};
});

Please note that debugger and console.log are not needed here, they were added just for testing the code.

 

As you can see the key actions here are:

 

- calling RightUtilities and checking if the user has operation permission rights for "CanExportDataOnCustomDetail" operation (the one that we've created at step 1)

- setting the "CanExportDataOnCustomDetailAtt" attribute value based on the RightUtilities check in the checkOperationPermission function

- using the "CanExportDataOnCustomDetailAtt" attribute value so to call getExportToExcelMenuVisibility method correctly due to our business task

 

As a result once the system user or role is added to the operation permission they will be able to see the "Export to Excel" button in the detail actions.

 

Best regards,

Oscar

Show all comments