Question

Attachement

Hi Team

It has to accept only png|.jpg|.gif format .if the candidate selects another format  it has to show a prompt like please select the valid format like the png|.jpg|.gif format.

please find the attachment below.Hoping for positive reply.

Regards

manikanta.

Like 0

Like

7 comments

I am trying in this way but its showing errors

var File = Entity.GetTypedColumnValue<string>("Name");

var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "UsrpracticeFile");

var id = esq.AddColumn("Id").Name;

new RegExp(@"/^([a-zA-Z0-9\s_\\.\-:])+(.png|.jpg|.gif)$/").test(File));

if (!isValid) {

invalidMessage = this.get("Resources.Strings.namevalidation");

    

}

return true;

Hoping for a positive reply

It's better to override the upload method in the FileDetailV2 module. If you need a server side validation then you'll need to create your own service based on the ConfigurationFileApi service and use it in the "upload" method. If it's enough to validate on the client side then just modify the "upload" method according to your needs. 

Eugene Podkovka,

Hi 

Eugene Podkovka,

Case Description: I want to restrict the user from uploading certain file formats. one of the ways I tried is mentioned below. can someone suggest a way to achieve this? if I override a method from file details, what is that method?

Code:

define("FileDetailV2", [], function() {

    return {

        entitySchemaName: "UsrpracticeFile",

        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,

        methods: {

            onFileSelect: function(files) {

            //    var parentMethod = this.getParentMethod(this, arguments);

                var FileName = files.Name;

                if (this.$CardPageName === "Usrpractice1Page") {

                    if (FileName.RegExp("/^([a-zA-Z0-9])+(.png|.jpg)$/")) {

                        this.showInformationDialog("Cannot add more than one file");

                    } 

                }/* else {

                    parentMethod();

                }*/

            }

        }

    };

});

If there any chance for sample one please help me out.hoping for positive reply.

Regards

manikanta

 

Please deploy the application locally. Then debug the "upload" method in the FileDetailV2 module while adding a new file. Please investigate a call stack and make make sure that you understand how the out-of-the-box functionality works. 

Regarding the specified code:

1. Please make sure that the entitySchemaName is correct. 

2. onFileSelect will probably work, but I would use "upload". 

3. parentMethod(); - what is this? Probably you meant this.callParent(arguments);

Eugene Podkovka,

    upload: function(files) {

                var parentMethod = this.getParentMethod(this, arguments);

                var FileName = files.Name;

                if (this.$parentMethod === "Usrpractice1Page") {

                    if (FileName.RegExp("/^([a-zA-Z0-9])+(.png|.jpg)$/")) {

                        this.showInformationDialog("Cannot add more than one file");

                    }

                } else {

                    parentMethod();

                }

            }

Hi Eugene 

I am trying in these still I am not getting a plz check once can u send me one example. (which method I have to override)

hoping for a positive reply.

It's fine. Please debug the method and adjust it according to your needs. Please don't ignore the 3-rd point.

3. parentMethod(); - what is this? Probably you meant this.callParent(arguments);

Hi Eugene Podkovka

Tnq for your solution it's working

Regards

manikanta.

Show all comments