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

Chaitanya Redd5
Tera Guru

Hi Nainitha,

 

Please make sure your UI type is ALL to work in service portal.

 

find_real_file.png

 

 

Please let me know if you have any questions.

Thanks,

Please Hit like, Helpful or Correct depending on the impact of the response.

 

Chaitanya Redd5
Tera Guru

Hi 

 

Try to use onSubmit script

 

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;

}

}

}

 

 

And please make sure your UI type is ALL to work in service portal.

 

Please let me know if you have any questions.

Thanks,

Please Hit like, Helpful or Correct depending on the impact of the response.

Hello Chaitanya,

Thanks for the reply!

i'm also using the same script, which is not working for order guides in service-portal and UI type is all for my client script

In the below UI Script that we are calling from client script is not able to find sc_cat_item element for order guides and its getting failed in try block and going to catch.

  

UI Script: GlobalCatalogItemFunctions

function getSCAttachmentCount() {

  var length;

  try {

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

  } catch(e) {

  length = -1;

  }

  return length;

}

Mike Patel
Tera Sage

Change #sc_cat_item to #sc_cat_item_guide in your code