Pop up Mandatory attachment message based on condition

Srinivasu2
Tera Contributor

Hi Community,

I have written below code for condition like when Data master is customer and Operation is New

the below code is not working for me, Could you please check and correct me where did i wrong

 

function onSubmit() {
    //Type appropriate comment here, and begin script below


    var data_master_val = g_form.getValue('data_master');
    var opr_val = g_form.getValue('operation');
 
       if (opr_val == "New") {

        try {
            var msg = 'Please attach the document before submitting this request';
            var attachments = document.getElementById('header_attachment_list_label');
            alert(msg);
            if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
                alert(msg);
                return false;
            }
        }

        //For Service Portal
        catch (e) {
            var count = getSCAttachmentCount();
            if (count <= 0) {
                alert('msg');
                return false;
            }

        }

    }
}
 
Please check below screenshot more about the requirement
 
Regards
Srinivasu

// 
3 REPLIES 3

Srinivasu2
Tera Contributor

Sorry, this is the code i have written 

 

function onSubmit() {
    //Type appropriate comment here, and begin script below


    var data_master_val = g_form.getValue('data_master');
    var opr_val = g_form.getValue('operation');

    if (data_master_val == 'Customer' && opr_val == 'New') {


        try {
            var msg = 'Please attach the document before submitting this request';
            var attachments = document.getElementById('header_attachment_list_label');
            alert(msg);
            if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
                alert(msg);
                return false;
            }
        }

        //For Service Portal
        catch (e) {
            var count = getSCAttachmentCount();
            if (count <= 0) {
                alert('msg');
                return false;
            }

        }

    }
}

// 

 

Hello @Srinivasu2 ,

Are you getting alert message that you have put in try or catch block ?

Hi Mohith,

 

No, I am not getting alert message

 

Regards,

Srinivasu