Mandatory attachment check on order guides in Service Portal not working

nainitha
Tera Contributor

Mandatory attachment check is not working on order guides in service portal, keep asking for the attachments over and over and not letting to proceed further.Any help on here is greatly appreciated.

Here is the code that i'm using, which is working fine for stand alone catalog items on both iframe and service-portal but not on order guides in service-portal.

UI Script: GlobalCatalogItemFunctions

function getSCAttachmentCount() {

  var length;

  try {

  length = angular.element("#sc_cat_item").scope().attachments.length;

  } catch(e) {

  length = -1;

  }

  return length;

}

 

This is an onSubmit script I am using for a catalog item:

 

function onSubmit() {

  try { //Works in non-portal ui

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

  if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {

  alert('You must attach the completed form before submitting this request.');

  return false;

  }

  } catch(e) { //For Service Portal

  var count = getSCAttachmentCount();

  if(count <= 0) {

  alert('You must attach the completed form before submitting this request.');

  return false;

  }

  }

}

 

1 ACCEPTED SOLUTION

nainitha
Tera Contributor

i got it worked with this code, might be useful for somebody who's looking for it.

 

find_real_file.png

View solution in original post

7 REPLIES 7

nainitha
Tera Contributor

i got it worked with this code, might be useful for somebody who's looking for it.

 

find_real_file.png

Thanks for providing the accurate solution, perfectly worked. 

Almost spent 6hrs but no result. 

Applied yours and its fixed!!!

Appreciate your efforts!!

Suresh Ch
Tera Contributor

I have used same code but it is not working for my catalog item. and below code

 if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {

  alert('You must attach the completed form before submitting this request.');

  return false;  ----->not giving any alert and 

 catch(e) { //For Service Portal

  var count = getSCAttachmentCount();

  if(count <= 0) {

  alert('You must attach the completed form before submitting this request.');

  return false;

  }

is giving alert continuously even after adding attachment please give me a solution.

 

Thanks,

Suresh Ch.