0
  1. Create UI Script
  2. Give Name: CatalogAttachmentMandatoryGlobal
function getCatalogAttachmentCount() {
    var length;
    try {
        length = angular.element("#sc_cat_item").scope().attachments.length;
        } catch(e) {
    length = -1;
    }
    return length;
 }

3. Create Onsubmit Catalog Client Script:

4. Name : ValidateAttachment

function onSubmit() {
 var type = g_form.getValue('request_type'); 
 if(type == "custom"){
  try { 
   var getAttachments = document.getElementById('add_attachment_button');
   if (getAttachments.style.visibility == 'hidden' || getAttachments.style.display == 'none' ) {
    alert('Please attach attachment to proceed');
    return false;
   }
  }
  catch(e) { //For Service Portal
   var attachmentCount = getCatalogAttachmentCount();
   if(attachmentCount <= 0) {
    alert('Please attach attachment to proceed');
    return false;
   }
  }
 }
}

5.Create JS Include under Theme

6. In the Left Navigator Bar, go to Service Portal > Portals

7.Select Portal you want to adjust.

8.Open the theme and add JS Include

Create New JS Theme
Display Name: CatalogAttachmentMandatoryGlobal
UI Script: CatalogAttachmentMandatoryGlobal

How to Make Attachment Mandatory on particular conditions on Service Portal and Native View
Working Code Edited question September 25, 2023
Sorry, you do not have permission to read comments.