Attachment should mandatory on service portal

keval3
Tera Contributor

Hi All,

I have create one service catalog in which there is one variable called Bank Statement, with type of yes and no.

when user select yes in Bank Statement at that time Attachment will be mandatory.

 

Please let me know how to resolved above requirement.

 

Thanks & Regards

KP

4 REPLIES 4

Samaksh Wani
Giga Sage
Giga Sage

Hello @keval3 

 

function onSubmit() {
    if (g_form.getValue("Field_value") == 'valueCheck') { //get the value
        try {
            var attachments = document.getElementById('header_attachment_list_label');
            if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
                alert("Please attach before submitting the request.");

                return false;
            }
        } catch (e) {

            if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
                alert('Please attach before submitting the request.');
                return false;
            }

        }
    }
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Danish Bhairag2
Tera Sage
Tera Sage

Hi @keval3 ,

 

There is an Attachment type variable which u can create in catalog item. You can then create a UI policy with condition as Bank statement is Yes & UI policy action as Attachment variable visible true & mandatory true. This way without scripting u should be able to force users to attach n attachment.

 

Thanks,

Danish

 

Hi Danish,

The Attachment is out of box I have not create it.

Thanks & Regards

KP

Yes @keval3 ,

 

The OOTB Attachment which we see on the portal for a catalog item in order to make that mandatory we need to take route of script. They way i have suggested above is script free way. Just create one additional field of type as attachment & make it mandatory when the other field is selected as Yes.

Attaching screenshots of how it will look like

 

DanishBhairag2_0-1700556015428.png

DanishBhairag2_1-1700556133252.png

 

Thanks,

Danish