Hi all,
I'm trying to delete access rights by code in a process. I've tried the following, but it can find the table "SyAccountRight".
public virtual void DeleteAllRights(UserConnection uc, Guid recordId, string sSchemaName) { string sRightSchemaName = "Sys" + sSchemaName + "Right"; var esqRights = new EntitySchemaQuery(uc.EntitySchemaManager, sRightSchemaName); esqRights.Filters.Add(esqRights.CreateFilterWithParameters(FilterComparisonType.Equal, "RecordId", recordId)); var entities = esqRights.GetEntityCollection(uc); foreach(Entity entity in entities) { entity.Delete(); } }
Maybe with DBSecurityEngine, but I can't find any documentation on this class.
Like
I'm not sure you can use ESQ with Sys*Right tables (I don't see entity schemas for those) but I've never tried. It might work to use Delete, although I've not tried this on those tables either.
Something like this:
var del = new Delete(UserConnection) .From("SysAccountRight") .Where("RecordId").IsEqual(Column.Parameter(recordId)) as Delete; del.Execute();
Ryan
Dear Jerome,
In order to delete from rights table you can use the Delete class on the server side.
Firstly, you need to get the userConnection in order to pass it in the Delete query:
var userConnection = Get<UserConnection>("UserConnection");
After that you can create a delete query:
var delete = new Delete(userConnection)
.From("Order")
//add conditions
.Where("Opportunity").IsEqual(opportunityId)
.Where("Product").IsEqual(productId);
And execute it:
delete.execute();
Here is more info on the Delete class in the development manual:
https://academy.bpmonline.com/documents/technic-sdk/7-13/deleting-data-…
Regards,
Anastasia
Ryan Farley,
I have tried using delete . It is not deleting the record and no errors found.
Pavan Manne,
Hi,
You can find an example of how to edit access right via code inside the system in the schema ChangeAdminRightsUserTask.
In there you can find methods AddRecordRight/DeleteRecordRight, you need to realize something similar to them.