Question

Operation permission in a process

Hi,

I created a new operation permission named "CanRunXXX"

When a user runs a specific process, I need to check if the user has the permission  to use it.

In the market place exists an addon specific for this feature https://marketplace.creatio.com/template/check-permission-operation

If I wanted to build it from scratch how can I do it?

Like 0

Like

7 comments

Hi Stefano,

 

Please install this marketplace app and analyze the content of the custom user task. It should contain some script inside it that receives the collection of allowed users that are stored in the operation permission users list. And this script can be used as an analogue to create your own user task if needed.

 

Best regards,

Oscar 

Oscar Dylan,

Thank you

Stefano Bassoli,

Hi

I tried to install the addon but it doesn't work

Any other suggestions ?

Stefano Bassoli,

I've installed the marketplace app and the following process worked perfectly on my end:

Basically the logic that checks if the current user has operation permissions rights is stored in the labCheckUserOperPermission class of the UserTask of the marketplace app:

protected override bool InternalExecute(ProcessExecutingContext context) {
			Success = (bool)UserConnection.DBSecurityEngine.GetCanExecuteOperation(OperationPermissionCode, UserConnection.CurrentUser.Id);
			return true;
		}

And returns either "true" or "false" for the "Success" parameter and the parameter itself determines if the process should be executed further or not. The full code of the UserTask can be found below:

namespace Terrasoft.Core.Process.Configuration
{
 
	using Newtonsoft.Json;
	using Newtonsoft.Json.Linq;
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Globalization;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.Configuration;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities;
	using Terrasoft.Core.Process;
	using Terrasoft.UI.WebControls.Controls;
 
	#region Class: labCheckUserOperPermission
 
	/// <exclude/>
	public partial class labCheckUserOperPermission
	{
 
		#region Methods: Protected
 
		protected override bool InternalExecute(ProcessExecutingContext context) {
			Success = (bool)UserConnection.DBSecurityEngine.GetCanExecuteOperation(OperationPermissionCode, UserConnection.CurrentUser.Id);
			return true;
		}
 
		#endregion
 
		#region Methods: Public
 
		public override bool CompleteExecuting(params object[] parameters) {
			return base.CompleteExecuting(parameters);
		}
 
		public override void CancelExecuting(params object[] parameters) {
			base.CancelExecuting(parameters);
		}
 
		public override string GetExecutionData() {
			return string.Empty;
		}
 
		public override ProcessElementNotification GetNotificationData() {
			return base.GetNotificationData();
		}
 
		#endregion
 
	}
 
	#endregion
 
}

So you can use something similar on your end as well.

 

Best regards,

Oscar

Hi Oscar 

In my environment doesnt appare in the user task list the new action 

Stefano Bassoli,

 

then you need to either re-install the marketplace app or check that your app is greater than 7.12 version and uses .NET Framework or use the code above to create your own user task to check operation permissions.

 

Best regards,

Oscar

Thank you very much

 

Show all comments