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

book

Article ID: 125348

calendar_today

Updated On:

Products

CA Service Catalog CA Service Management - Asset Portfolio Management CA Service Management - Service Desk Manager

Issue/Introduction

N/A

N/A

Environment

Windows

Resolution

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;