特定のカタログアイテムを起票する際にzipファイルの添付を禁止したいのですが、何か良い方法はありますか?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
特定のカタログアイテムをポータルから起票する際にzipファイルの添付を禁止したいのですが、何か良い方法はありますか?
テキストファイルをメインに添付したいと考えております。
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
you can use OOTB attachment variable in your catalog item and then add list of allowed extensions via variable attributes
allowed_extensions=jpg,png,pdf,doc,docx
OR
if you are planning to use the OOTB paper-clip icon and want to restrict then you will require custom onSubmit script for this
sample like this, it grabs all the file names and then you can check if user attached zip then stop form submission
function onSubmit() {
//Type appropriate comment here, and begin script below
var countRequired = 1;
if (window == null) {
// portal
if (this.document.getElementsByClassName('get-attachment').length != countRequired) {
alert('You must add 1 attachment before submitting this request.');
return false;
}
} else {
// native view
var length = $j("li.attachment_list_items").find("span").length;
if (length != countRequired) {
alert('You must add 1 attachment before submitting this request.');
return false;
}
}
var arr = [];
if (window == null) {
// portal
var z = this.document.getElementsByClassName("get-attachment ng-binding ng-scope");
var k;
for (k = 0; k < z.length; k++) {
var value = z[k].innerHTML;
value = value.substring(0, value.indexOf('('));
arr.push(value.trim());
}
} else {
// native get all the file names
$j("a.content_editable").each(function(index) {
var val = $j(this).text();
arr.push(val);
});
}
var allowedExtension = '.pdf';
var isAllowed = true;
for (var i in arr) {
if (arr[i].indexOf(allowedExtension) == -1) {
isAllowed = false;
break;
}
}
if (!isAllowed) {
g_form.addErrorMessage('Please add only pdf files');
return false;
}
}
Ensure Isolate Script = False for this client script to allow DOM
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
