Hi Community,

 

I have follwed the following article to add a validation on attachment object using Entity Events Layer:

Article: https://community.creatio.com/questions/how-restrict-attachment-upload-specific-conditions

 

The above logic is working as expected when I am uploading files of small size (< 500 KB). But the issue happens when I try to upload larger files, the following popup appears instead of the custom exception.

 

Any suggestion how to resolve the issue for larger files?

 

Thanks,

Sourav Kumar Samal

Like 0

Like

2 comments

Hello,

 

The logic provided in the previous post doesn't depend on the file size (that is specified in the system setting with "MaxFileSize" code). Additionally it doesn't use file locator in it, it only uses values from the account object column and compare it to the current date and time. There should be another custom logic that generates this exception, something that is triggered when adding the file to the system and if the upload is restricted another logic stops its execution with this exception.

 

Best regards,

Oscar

Oscar Dylan,

 

I have added the following code:

 

		#region Methods: Public
 
		public override void OnFileSaving()
		{
			var ClaimId = Entity.GetTypedColumnValue&lt;Guid&gt;("ClaimsId");
			var ResultESQ = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Claims");
			ResultESQ.UseAdminRights = true;
			ResultESQ.AddColumn("Id");
			ResultESQ.AddColumn("ClaimStatus");
			var Result = ResultESQ.GetEntity(UserConnection, ClaimId);
			var DCMStatus = Result.GetTypedColumnValue&lt;Guid&gt;("ClaimStatusId").ToString();
 
			if(DCMStatus == "ff78a06e-9d37-474a-841c-32a8faaa7776" || DCMStatus == "13c42d45-0fb9-4854-9a5d-5a5feb126db2" || DCMStatus == "19226327-e2ff-420c-937e-c36949be4425"
				|| DCMStatus == "3adf1d1d-bc90-475b-b24b-ca837e9ca9fc"|| DCMStatus == "942af147-3fc9-4a80-89aa-76f0412e0ade"){
			    base.OnFileSaving();
			}else{
			    throw new Exception("Attachments can not be added as Claim is already Submitted.");
			}
		}
 
		#endregion

When the file size is small, the following popup is coming:

 

 

When the file size is large, the following popup comes up:

 

 

The above popup comes only when the above condition is met. We have not implemented any other logic for this object. Could you help us here with what might be the cause of the issue, when it is working fine with smaller files but not with larger files.

 

Thanks,

Sourav Kumar Samal

Show all comments