How to make mandatory more than one attachment (console view i want ) in client script ?

Sai136
Kilo Expert

script working in portal view ......

but console view if i attach one attachment it is allowing to submit ticket ,but requirement   is   2 attachment mandatory  

so that is not working in console view...

 

function onSubmit() {

//Type appropriate comment here, and begin script belo

if (g_form.getValue('request') == 'Job')
{
try {

var msg = 'Please attached the job template(s) required and the COE approval email ';

var attachments = document.getElementById('header_attachment_list_label');

// g_form.addInfoMessage("Attachment visibility: " + attachments.style.visibility + " attachment display: " + attachments.style.display);

if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert(msg);
return false;
}
}
// For Service Portal
catch (e) {
var count = getSCAttachmentCount();
if (count <=1)
{
alert(msg);
return false;
}
}

}

}

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sai,

please refer below blog and it would help you solve that;

Verify Mandatory Attachments Count on Catalog Item

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

DirkRedeker
Mega Sage

Hi

I recommend to implement a "before insert/update" Business Rule on the table, where you want to have the attachment.

In that business rule, GlideRecord to the attachment table, to count the number of current attachments on you current record.

If there are not enough, cancel the business rule, with showing à warning messages.

Let me know if that answered your question and mark my answer as correct and helpful

BR Dirk

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sai,

please refer below blog and it would help you solve that;

Verify Mandatory Attachments Count on Catalog Item

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader