-
-
Save wave-inguane/5d382f5591ff96dcb58327288653cd60 to your computer and use it in GitHub Desktop.
Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*******************************************************Attachment Required************************************* | |
//Catalog Client Script | |
//Applies to: A Catalog Item | |
//Type: onSubmit | |
//UI Type: All | |
//Applies to a Catalog Item View : True | |
/****************************************************************************************************************/ | |
function onSubmit() { | |
try { | |
var value = g_form.getValue('xyz'); | |
var count = 1; | |
if(value == 'yes'){ | |
if(window == null){ | |
// portal | |
if(this.document.getElementsByClassName('get-attachment').length != count) { | |
alert('do what'); | |
return false; | |
} | |
}else{ | |
// native view | |
var length = $j("li.attachment_list_items").find("span").length; | |
if(length != countRequired){ | |
alert('do what'); | |
return false; | |
} | |
} | |
} | |
} | |
catch(err){ | |
var error_message = err.message; | |
jslog("ERROR : " + error_message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*******************************************************Attachment Required************************************* | |
//Catalog Client Script | |
//Applies to: A Catalog Item | |
//Type: onSubmit | |
//UI Type: All | |
//Applies to a Catalog Item View : True | |
/****************************************************************************************************************/ | |
function onSubmit() { | |
var msg = getMessage("Please use the paperclip icon below to attach only CSV file(s) for reference."); | |
try | |
{ | |
//for non-portal | |
var attachments = document.getElementById('header_attachment_list_label'); | |
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') { | |
alert(msg); | |
return false; | |
}else{ | |
var flag = true; | |
var sysid =g_form.getElement('sysparm_item_guid').value; | |
var attachment = new GlideRecord("sys_attachment"); | |
attachment.addQuery("table_name", "sc_cart_item"); | |
attachment.addQuery("table_sys_id", sysid); | |
attachment.query(); | |
while (attachment.next()) { | |
if(attachment.file_name.indexOf(".csv") == -1){ | |
flag = !flag; | |
break; | |
} | |
} | |
if(flag == false) | |
alert(msg); | |
return flag; | |
} | |
}catch(e){ | |
//for-portal | |
if(this.document.getElementsByClassName('get-attachment').length > 0) { | |
var arr = this.document.getElementsByClassName('get-attachment'); | |
for(var j = 0; j < arr.length; j++){ | |
var value =(arr[j].innerHTML).toLowerCase(); | |
if(value.indexOf('.csv') == -1){ | |
alert(msg); | |
return false; | |
} | |
} | |
return true; | |
} | |
else if(this.document.getElementsByClassName('get-attachment').length <1) | |
{ | |
alert(msg); | |
return false; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment