Hi community!

How are you?

I hope you can help me with the following

 

I have a query with ESQ on "EmployeeMiniPage" to validate that the "NroLegajo" field in the Employee entity is not repeated. When I apply certain permissions on a record so that only certain users can see it, the query not consider that record when I log in with a user who does not have permissions, and therefore allows me to enter an existing "NroLegajo" that belongs to that record. To solve this I set the "QueryJoinRightLevel" system variable with value "2" (Disabled) but it does not work. 

 

I reassigned and denied permissions on the registry to do the test and when I logged in with the user who does not have permissions on the registry I can continue entering a repeated value in the field "NroLegajo"

Any idea?

Is there an alternative a ESQ?

King Regards,

Ezequiel

Like 1

Like

14 comments

Dear Ezequiel,

In order to omit rights check you can create an ESQ on the server side by the means of C#. However, instead of using UserConnection, you can use SystemUserConnection, which would let you execute the functionality no matter under what user.

"Script task" business process element or service will perfectly fit and cover the task. Choose the means more comfortable for you.

Here is how to obtain SystemUserConnection:

private SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}

Here is an article of how to build ESQ on server side. Though, its pretty much the same as on the client side:

https://academy.bpmonline.com/documents/technic-sdk/7-11/use-entitysche…

Hope you find it helpful.

Regards,

Anastasia

Hi Anastasia!

Thanks you for your answer!

How could I validate in the Employee registration that the "Legajo" field value is not repeated in the way you are indicating?

 Can I call a business process from EmployeeMiniPage to return an answer?

I need that validation along with others before saving the employee!

King Regards!

Ezequiel

 

Dear Ezequiel,

In order to implement such functionality on the page, you need to do the following;

1. Create a webservice, which brushes through the Employee table for duplicates. Please see more details on how to write a service here:

https://academy.bpmonline.com/documents/technic-sdk/7-8/how-call-config…

2. Create a new virtual boolean attribute. We will use it in our further steps.

            "ESQCompleted": {
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
                value: false
            }

3. Override a basic save() method and firstly insert a validation, that if this.get("ESQCompleted") true, than we call parent function, if not, than run service call, as in the article.

4. In the response, based on the result, you either show information dialog regarding existing duplicate, or set attribute to true and call save method again.

Regards, 

Anastasia

Dear Anastasia,

Sorry, for the delay in the response. When working with the service I found several errors, I could not include the SystemUserConnection variable because it was throwing errors and when working with UserConnection as a test I also get several errors. Am i missing a reference?. I attach the code

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
	// Service class is marked with [ServiceContract] compulsory attributes and
	// [AspNetCompatibilityRequirements] with parameters.
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
		/*private SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}
		}*/
		// Service methods are marked with compulsory attributes [OperationContract] and [WebInvoke] with parameters.
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
			//var result = nroLegajo + " + output string";
			var result = "T";
			entitySchemaManager = UserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			//Agrego filtros en el query
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
 
			// Adding created filters to query collection.
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			// Execution of cache to database and getting resultant collections of objects.
			// Query results will be placed in cache after completion of this operation.
			var employeeCollection = esqEmployee.GetEntityCollection(UserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

The errors that appear to me are the following:

I hope you can help me!

King Regards,

Ezequiel

 

Dear Ezequiel,

The reason for an error with UserConnection, is that you are missing "var" in variable declaration:

var entitySchemaManager = UserConnection.EntitySchemaManager;

As for the SystemUserConnection, please add the _systemUserConnection property declaration before the code I have previously indicated, like this: 

private SystemUserConnection _systemUserConnection;
private SystemUserConnection SystemUserConnection {
	get {
	     return _systemUserConnection ?? (_systemUserConnection = 
        (SystemUserConnection)AppConnection.SystemUserConnection);
	}
}

Hope this will solve the issue.

Regards,

Anastasia

Dear Anastasia!

How are you? Thank you for your answer!

Could it be that I'm missing a reference? I attached image

Regards!

Ezequiel

Dear Ezequiel,

Please try to make variable, which you assign SystemUserConnection, of a static type. In case this won't help, please share the whole code.

Regards,

Anastasia

Dear Anastasia,

I continue with the problem. I attached code.

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
 
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
		private static SystemUserConnection _systemUserConnection;
		private static SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}
		}
 
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
 
			//var result = nroLegajo + " + output string";
			var result = "T";
			var entitySchemaManager = SystemUserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			var employeeCollection = esqEmployee.GetEntityCollection(SystemUserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

Thanks you for your help!

King Regards!

 

Dear Anastasia!

 

I have to say that removing the definition of SystemUserConnection and using UserConnection I get a similar error

King Regards!

Ezequiel

Dear Ezequiel,

Please find the modified code for your service. I have successfully tested it on my side:

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using System.Web;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
 
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
 
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
			var appConnection = HttpContext.Current.Application["AppConnection"] as AppConnection;
 
			//var result = nroLegajo + " + output string";
			var result = "T";
			var entitySchemaManager = appConnection.SystemUserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			var employeeCollection = esqEmployee.GetEntityCollection(appConnection.SystemUserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

 

Dear Andrey,

You have to use only UserConnection in GetEntityCollection method. Here is a signature of a method:

public EntityCollection GetEntityCollection(UserConnection userConnection)

Peter Vdovukhin,

Dear Peter,

Thank you for answer! May be you know how to get UserConnection on start appliacation (without users)? 

Dear Andrey,

Could you create a new topic with this question? It will be available for search and may be helpful for others.

Could you try instead of:

var SysAdminUnitCollection = esqSysAdminUnit.GetEntityCollection(appConnection.SystemUserConnection)

write:

var SysAdminUnitCollection = esqSysAdminUnit.GetEntityCollection((SystemUserConnection)appConnection.SystemUserConnection)

The thing is that SystemUserConnection inherits from UserConnection so you can pass SystemUserConnection instead of UserConnection

 

Show all comments

Hi Community!

How are you? I hope you can help me!

I have configured permissions managed by operations, in which I restrict reading to contacts for certain roles. That brings me problems when reading contact data from a business process, even though it gives permission to the contact from the process, the reading does not work. How could I hide the contacts section without losing access to them from another object?

King Regards!

Ezequiel!

Like 0

Like

3 comments

Dear Ezequiel,



If your goal is just to hide the contacts section but you want to get the ability to read the contacts information for all users, you can try to delete it from the General workplace so that all employees won't see it and restore the read operation permissions to all system users.



System designer -> Workplace setup:

Image.png

You can add this section to any other workplace and manage the access rules to it or create your own to fulfill your needs.

Best regards,

Lily

Hi Lily!

Thanks for the reply. I delete the section from the General workplace and restore the read operation permissions to all system users. How could I hide the link to Contacts from the main page?

 

 

 

 

King Regards,

Ezequiel Gómez

Dear Ezequiel,

To hide the link to the section from the main page you need to go to the Configuration, replace SimpleIntro schema, copy the code from the original schema to it and apply the necessary changes to the code. Specifically, to hide the link to the Contacts section, you need to comment the following code part:

Image.png

Show all comments

Hi Community!

How are you? I hope you can help me!

I have configured in Account two lookup fields with "VwSysRole" as dictionary to associate roles with the account

but after adding them, I can not update the entity (BD), it throws an error.

However, I have a business process that takes those values ​​as parameters to set Access Rights in certain situations, and that works correctly. For example, when an account is added

How could you update the DB or what dictionary could I set in those fields to be able to associate the roles with the account without generating inconsistencies in the DB?

King Regards,

Ezequiel

Like 0

Like

1 comments

Unfortunately you will not be able to create a field linked to the VwSysRole view in the account object. VwSysRole is not a table. It's a view and it doesn't allow all of the operations that you can do with a table. 

Additionally, account is a unit that is not related to the system roles. Simply, you can't login with an account. Even contacts are not linked to system roles directly. 

Only admin units that you can find in the system section "System users" are linked to roles directly. Basically, when the system decides what permissions you should have, the system looks at the login credentials that you used and it doesn't look at your contact or an account.

Show all comments

Hi Community!

How are you?

I hope you can help me!

 

I want to make a query with filters where the equivalent in sql server for example would be: "..Where field = 'Administrator' OR  field like 'Ope%' or field like 'Supe%'

 

 

Is there any way to include combinations of AND and OR with ESQ? Is there an alternative?

King regards,

Ezequiel

Like 0

Like

4 comments

Dear Ezequiel,

You can create the filter that would include AND and OR at the same time and would work as described. 

You need to build the filter as shown in the following example:

                var filters = Ext.create("Terrasoft.FilterGroup");
                filters.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;
                filters.addItem(select.createColumnFilterWithParameter(Terrasoft.ComparisonType.START_WITH, "UsrPresents",
                               present.value));
                select.filters = filters;

 

Lisa

Hi Lisa! 

Thank you for you answer!

sorry, I expressed myself badly, I need to add a filter. The complete filter would be:

Where Id = 'some id' and (name = 'Administrator' OR  name like 'Ope%' or name like 'Supe%')

Can be done?

Regards,

Ezequiel

I show the example below

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
				rootSchemaName: "SysUserInRole"
});
esq.addColumn("[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", "RolFuncionaAsociado");
var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "SysUser.Id", userId);
var esqFilter2 = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", nombreRol);

The second filter is who should have the OR combination

Regards,

Ezequiel

You can use my example above to create the correct filtration. Just make sure you add all the necessary filters to the collection and then combine them in the way you need. You can use the following example to add the filters to the collection:

// Adding created filters to query collection. 
esqCities.Filters.Add(esqFirstFilter);
esqCities.Filters.Add(esqSecondFilter);

More useful examples can be found in our Academy here - https://academy.bpmonline.com/documents/technic-sdk/7-11/use-entityschemaquery-creation-queries-database.

Lisa

Show all comments

Hi Community!

How are you?

I hope you can help me!

I want override "DELETE" button from the Employee Grid,

For that, edit EmployeeSection and overwrite the "deleteRecords" method. However, the permissions applied to the "Delete" action were lost

 

I want to overwrite the method but respecting the configured permissions

Any idea?

King Regards,

Ezequiel

Like 0

Like

1 comments

Dear Ezequiel,

Overwriting the method shouldn't impact the access right set for the object as you overwrite it in JS on the user side and the access rights are configured in the back-end in C#.

Please check the functionality again and if there are still some malfunctions provide us with the detailed description of all the actions taken by you and the result you got. You can either answer here, or send the detailed email to support@bpmonline.com so we could take a look. 

Lisa

 

Show all comments

Hi everyone!

How are you?

I hope you can help me

I want know if a user have associated a functional role in his organization role.

Example: User: "apaez", Organization Role : "Operador Arcor", Functional Role: "Operador Empresa"

The user "apaez" is asocciatted the "Operador Arcor" Organization Role and "Operador Arcor" Organization Role is associatted "Operador Empresa" Functional Role

The query that builds in SQLServer is the following:

SELECT * FROM SysUserInRole ur

  JOIN SysFuncRoleInOrgRole a ON ur.SysRoleId = a.OrgRoleId

  JOIN VwSysRole sr ON a.FuncRoleId = sr.Id

Where sr.Name = 'Operador Empresa'

AND ur.SysUserId = '20abeba5-5327-45aa-a5c2-07c41ac1fdf2'

 

How can I replicate it in ESQ (Client)?

King Regards,

Ezequiel!

 

 

Like 0

Like

2 comments

Maybe this example can help

	function getUserSaveRights(callback, renderTo, scope) {
		var currentUser = Terrasoft.SysValue.CURRENT_USER.value;
		var sysAdmins = ConfigurationConstants.SysAdminUnit.Id.SysAdministrators;
		var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
			rootSchemaName: "SysUserInRole"
		});
		esq.addColumn("SysRole");
		esq.addColumn("SysUser");
		esq.filters.add("SysUser", Terrasoft.createColumnFilterWithParameter(
			Terrasoft.ComparisonType.EQUAL, "SysUser", currentUser));
		esq.filters.add("SysRole", Terrasoft.createColumnFilterWithParameter(
			Terrasoft.ComparisonType.EQUAL, "SysRole", sysAdmins));
		esq.getEntityCollection(function(response) {
			if (response && response.success) {
				var result = response.collection;
				var isSysAdmin = (result.collection.length !== 0);
				callback.call(scope, renderTo, isSysAdmin);
			}
		}, this);
	}

 

Federico,

Thanks for you help!

I was able to solve the query in the following way:

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
						rootSchemaName: "SysUserInRole"
					});
esq.addColumn("[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", "RolFuncionaAsociado");
 
var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "SysUser.Id", userId);
var esqFilter2 = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", nombreRol);
esq.filters.add("esqFilter", esqFilter);
esq.filters.add("esqFilter2", esqFilter2);
esq.getEntityCollection(function (result) {
   if (!result.success || result.collection.collection.length == 0) {
		// error processing/logging, for example
		this.showInformationDialog("Data query error");
		return;
   }
   debugger;
   this.set(nombreRol, true);
   return;
}, this);

King Regards!

Ezequiel

Show all comments

Hi!

How are you?

I hope you can help me!

I have an Employee printable and I added some related tables, among them, Employee's career, where the IsCurrent field is Boolean, and the same in the report is shown with the value "True" or "False", there is a way to show "Yes" or "No" instead of "True" or "False"?

King Regards,

 

Ezequiel

Like 0

Like

1 comments

Hi!

How are you?

I hope can you help me!

 

I have a permission in Employees where the records created by "Operator Arcor" (Organizational Role) can only be seen by someone from that Role or a Supervisor

 

When I create an employee with the "Supervisor" user, I want to modify the "Created By" field to set it to the Contact of a user of "Operador Arcor" role, and in that way, to see that record within that role.

To do that, I create a business process where I modify this field if it was created by the Supervisor, but for some reason I do not see the record in the Employees section when I log in with a user of that role

am I still missing something more in the process?

The fields that I update are "Created By" and "Owner".

The same test with Contact instead of Employee works ... That is, I can see the contacts with some user of the role "operator Arcor", where the field Created By was set through the business process

King Regards!

Ezequiel!

Like 0

Like

1 comments

Dear Ezequiel,

The default access rights for the record are distributed while the creation process. In other words, when you change the owner or the created by filed using a business process, the rights won't be re-distributed.

In your case, you just need to add the [Change access rights] element after you change the owner and the author of the record to redistribute the rights to the corresponding users. The more detailed info about this element: https://academy.bpmonline.com/documents/technic-bpms/7-11/change-access-rights-process-item

Best regards,

Lily

 

Show all comments

Hello!

How are you?

I hope your help me!

Is there any way to export all or part of the database from a Cloud enviroment, including tables that contain files?

Regards,

Ezequiel 

Like 0

Like

1 comments

Ezequiel you can send the request to support and they send you a backup of the database. Is not posible access to the database in cloud sites.

Show all comments

Hi!

How are you?

I hope you can help me!

How can I add the Employee image to my printable template? I add the "Photo" field of the Contact associated to Employee to template but it show an Guid instead of the Photo.

Thank you!

Regards,

Ezequiel

Like 0

Like

1 comments

Dear Ezequiel,

To get the picture of the contact, please check the screenshots below:

 Then within the contact object, please find photo and choose the image:

Within the printable template it Word it will look in such a way:

Best regards,

Lily

Show all comments