Restrict Multiple File attachments

Is there any way to restrict number of file to be attached in the attachment detail tab.

I need a situation like user have to attach only one file in the section wizard and not more than that

Like 0

Like

2 comments

Hello,

 

Your business task requires additional development, as of now it cannot be achieved with basic tools only. 

 

We've registered a query for our responsible R&D team to implement the described functionality in the upcoming versions of a system.



Best regards,

Anastasiia

Kavya,

 

To achieve your business task follow the below approach,

Create a replacing module for "FileDetailV2" and add the below code,

define("FileDetailV2", [], function() {
	return {
		mixins: {},
		attributes: {},
		methods: {
			onFileSelect: function(files) {
				var fileSchemaName = this.entitySchemaName;
				if(files.length > 1 && fileSchemaName == "UsrCustomObjectFile"){ //Your file object name goes here
					this.showInformationDialog("More than 1 files are not allowed.");
					return;
				}else{
					this.callParent(arguments);
				}
			},
			upload: function(config, callback) {
				var fileSchemaName = this.entitySchemaName;
				if(fileSchemaName == "UsrCustomObjectFile"){ //Your file object name goes here
					this.CustomAttachmentCountValidation(config);
				}else{
					this.callParent(arguments);
				}
			},
			CustomAttachmentCountValidation: function(config, callback){
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: this.entitySchemaName 
				});
				esq.filters.addItem(esq.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "UsrConnectedColumn", this.get("MasterRecordId")));	//Master entity Connected column
				esq.getEntityCollection(function (result) {
					if (result.success && result.collection.getCount() > 0) {
						this.showInformationDialog("More than 1 files are not allowed.");
					}else {
						this.Terrasoft.ConfigurationFileApi.upload(config, callback);
					}
				}, this);
			},
		}
	};
});

Let me know if this helps in achieving your objective.

 

Warm Regards,

Sourav Kumar Samal

Show all comments