In the academy documentation, there is limited information about using the ESQ/ORM server-side methods to delete data, with only 2 or 3 toy examples. We need to efficiently delete large volumes of data using server-side ESQ in one of our processes, but we can't see anything about bulk deleting while still firing off any event-based triggers on the entity or generating change log records for it. Obviously the direct Terrasoft.Core.DB delete statement would be very efficient, but would skip the Creatio logic where needed.

 

We've been able to delete records by iterating over a collection of entities matching the required filtering condition retrieved by using GetEntityCollection and then for each entity in the collection, running a FetchFromDB on its Id before deleting it, but this seems like quite a few steps more than should be required and doesn't do it in a batched way.

 

Any help would be greatly appreciated.

Like 0

Like

2 comments

Hello Harvey,

 

You can use out-of-the-box examples of bulk deletion logic. For example we can take the BulkEmailTargetArchiver class and the DeleteArchiveLevel method in it:

private void DeleteArchiveLevel(string sourceSchemaName, string targetSchemaName) {
			int processedRecords;
			do {
				var deleteQuery = new Delete(_userConnection).From(sourceSchemaName)
					.Where("Id").In(new Select(_userConnection)
						.Top(_batchSize)
						.Column("s", "Id")
						.From(sourceSchemaName).As("s")
						.Where().Exists(new Select(_userConnection)
							.Column(Column.Parameter(1))
							.From(targetSchemaName)
							.Where(targetSchemaName, "Id")
							.IsEqual("s", "Id")));
				processedRecords = deleteQuery.Execute(_dbExecutor);
			} while (processedRecords != 0);
		}

This is just one example of the logic. You can use:

 

select * from SysSchemaSource

where Source like '%DeleteQuery%'

 

to get other schemas in the application configuration with delete queries examples and build your own one using all examples you may find in the system.

Hi Oleg,

 

using these Delete classes bypasses Creatio’s internal logic though, right? So change logs will be inaccurate and any BPs that should be triggered on delete would not be triggered etc. This seems risky to me as important processes could hang off this, and I don’t know what other internal aspects of Creatio might be relying on logic that Creatio manages at an application level.

 

Is there any way to bulk delete while respecting that?

Show all comments

Hi community,

There is a system user needs to operate with records in several different objects. But I don't want that user can delete any records

Is there any way to set up permission for that?

 

Thank you!

Like 0

Like

1 comments

Hi, yes, there is a way to set it up. The necessary information you will find in this article: https://academy.creatio.com/docs/user/setup_and_administration/user_and…

Show all comments

Dear Community,

 

is there any way to block the deletion of records of an object for all users and user groups (including system administrators and the supervisor) depending on a lookup value, such as a status.

Adjusting the object permissions still let's sysadmins delete a record.

 

Like 0

Like

1 comments

Hello Markus,

You can write your own EventListeren on onDeletnig event and if your condition is satisfied, you can call base.OnDeleting(sender, e).

If not, it will block the delete action no matter who is the user.

public override void OnDeleting(object sender, EntityBeforeEventArgs e) {
				var entityOrderProduct = (Entity)sender;
            	var OrderProductid = entityOrderProduct.PrimaryColumnValue;
				string name = entityOrderProduct.GetTypedColumnValue<string>("Name");
				if (name != 'someting'){
					base.OnDeleting(sender, e);
				}
			}

 

Show all comments

How to recover a deleted contact?

Like 0

Like

3 comments

Hello Artem,

 

If the contact was fully deleted from the system, it cannot be restored, sorry.

WHat if that contact was merged, instead of deleting of it? can we see merged record's information in somewhere? 

Ismet Sinan Ekici,

There is no such possibility in our system.

Show all comments

Hello community,

 

Is there any function like the save: function(), but that is triggered by the deletion of a record?

Like 0

Like

3 comments

Hello,

 

Could you please describe what logic exactly you are trying to achieve in more detail?

 

Best regards,

Mira

Mira Dmitruk,

I am trying to do some operations when I delete a record.

If the function is lets say, onDelete: function() {

       this.callParent(arguments); // here the item will be deleted

       // here is my code, that needs to get triggered only when a record is deleted. this is mainly what I am looking for

}

 

Thank you!

The function is called (for both Sections and Details) is "deleteRecords" - this is implemented in the GridUtilitiesV2 mixin used by details and section lists. However, be aware there are many ways a record can be deleted. It might be best to implement any logic that needs to occur on record deleted as a process rather than in any/all places where the record could be deleted in the UI?

Ryan

Show all comments

Hi Community,

 

Any example how to do server side esq to delete records with multiple filter condition?

 

Thanks

Like 0

Like

1 comments

Hello Fulgen,

 

You can find many examples by searching terrasoft source code files if You have local instance of Creatio.

 

One of example with multiple filters is from UpdateTargetAudienceProcessHelper.MarketingCommon.cs

		public virtual void ClearCurrentTargets() {
			new Delete(UserConnection)
	.From(TargetSchemaName)
	.Where("IsFromGroup").IsEqual(Column.Parameter(true))
	.And(TargetSchemaBindingColumnValueName).IsEqual(Column.Parameter(RootSchemaRecordId))
	.And(ResponseColumnName).IsEqual(Column.Parameter(DefResponseId))
	.Execute();
		}

 

Best regards,

Marcin

Show all comments

Dear Community,

 

Does anyone know a way of recovering a deleted record?

More specifically, a deleted contact? 

 

If this is not an OOB functionality, is there a way to activate this manually or with a marketplace addon?

Thank you in advance!

 

 

Kind regards,

Yosef

Like 0

Like

1 comments
Best reply

Hello Yosef,

 

As for now there is no easy way to restore the record in case it was deleted. As an option, you can restore the instance where the record was deleted from the previously created database backups to restore deleted data.

We also have a problem registered to our R&D team to implement the easy records restoration functionality in one of future versions of the application. I will assign this case to the project in order to increase its priority.

Thank you for helping us to make our application better!

 

Best regards,

Anastasiia

Hello Yosef,

 

As for now there is no easy way to restore the record in case it was deleted. As an option, you can restore the instance where the record was deleted from the previously created database backups to restore deleted data.

We also have a problem registered to our R&D team to implement the easy records restoration functionality in one of future versions of the application. I will assign this case to the project in order to increase its priority.

Thank you for helping us to make our application better!

 

Best regards,

Anastasiia

Show all comments

Hi Community,

 

We are unable to delete records "used in another process". We tried both "Delete connected records also" and "Do not deleted connected records" but it is just going over and over again to another page where you are asked again to choose between the two options.

 

Thank you

Like 0

Like

3 comments

Dear Fulgen,



Please, create a ticket for technical support mentioning the name of your instance and providing external access to it.



Thank you in advance,

Ivanna.

Hi,

 

did you find a solution for this?

 

We are having the same problem and would really need a solution!

 

Thanks and br,

Robert

Ivanna Yatsura,

 

This is in our on premise system, could you provide the solution please, We will execute it ion our on premise system.

Show all comments

Hi Community,

 

Why am I getting timeout error when deleting records in any of the section. How can I fix it? Thank you so much

Like 0

Like

2 comments

Hi Fulgen,

 

This screenshot gives no information on the actual reason for the problem unfortunately.

 

What you need to do is:

 

1) If this is a local app - check the WebSockets settings in the app (this article will be useful). This is the most probable reason why records cannot be deleted in any section as you state. Also check if the "WebSocket" feature is enabled in the IIS-server Windows features.

 

2) Check the MultiDeleteQueue table and which messages do you receive there (no matter which instance cloud or on-site you have).

 

3) Check the application logs via C:\Windows\Temp folder (if this on-site .NET Framework app or Logs folder in the root binary files if this is a .NET Core app). If this is a cloud-based app you can approach us at support@creatio.com and we will provide you with the logs needed.

 

Best regards,

Oscar

Oscar Dylan,

Hi Oscar



Delete is very slow then it will pop up this generic error message "

Error occurred during the deletion of data. Please contact system administrator." Then after you refresh the section page for Example Account section, the record was already deleted.

Show all comments

If I wanted to redirect the Delete for an attachment detail record to a business process, instead of deleting the record, how would I do that?

Like 0

Like

1 comments

Dear Janine, 

To do this you need to create a replacing schema for FileDetailV2 and override method deleteRecords, starting process inside this method. To start process from the js code you can try the article below: 

https://customerfx.com/article/programmatically-starting-a-process-from-client-code-in-bpmonline/

Best regards,

Dennis 

Show all comments