How to configure attachement required via form script in CA Service Catalog

Document ID : KB000125348
Last Modified Date : 28/01/2019
Show Technical Document Details
Introduction:
N/A
Background:
N/A
Environment:
Windows
Instructions:
Please create the following code in the script on the form.
Use the following JavaScript to check the number of attachments associated with the request.  
This script sets a variable to the number next to the Attachments link.

var attachments = document.getElementsByName("attachments-1")[0].innerText.match(/\(([^)]+)\)/)[1];
if(attachments == 0){
  alert("Please add an attachment then press Submit again.");
  return false;
} else {
  console.log(attachments + ' attachments found');
  return true;