- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 12:44 AM
Hi All,
We have requirement when we submit the request from portal for specific catalog item Attachment is mandatory. But attachment should be a TEXT or Sql.
validates the attachment it would be either .txt or .sql and content should be available.
please help me how can we achieve this requirment.
Thanks,
Varma
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:51 AM
Hi @Sohail Khilji ,
Thanks for the solution.
I got the error while creating onload client script. Im not able to identify the what mistake on the script.
Please suggest.
Thanks,
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:54 AM
remove the try block keep the script only within onLoad function.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 01:09 AM - edited 05-15-2024 01:11 AM
Hi @varma2 ,
Create onsubmit client script which validates the file which is loaded.
function onSubmit() {
// Type appropriate comment here, and begin script below
var arr = [];
var extensions = ['.txt','.sql'];
try {
var names = this.document.getElementsByClassName('get-attachment ng-binding ng-scope');
if (names.length === 0) {
alert('Please attach at least one file.');
return false;
}
for (var i = 0; i < names.length; i++) {
var val = names[i].innerHTML;
arr.push(val.toString());
}
for (var j = 0; j < arr.length; j++) {
var isValid = false;
for (var k = 0; k < extensions.length; k++) {
if (arr[j].indexOf(extensions[k]) !== -1) {
isValid = true;
break;
}
}
if (!isValid) {
alert('Please give files with one of the following extensions: ' + extensions.join(', '));
return false;
}
}
}
}
OR >
You can create a script include and a onsubmit client scirpt using ajax call you can validate the type of file attached to the catlaog before submission,
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:51 AM
Hi @Sohail Khilji ,
Thanks for the solution.
I got the error while creating onload client script. Im not able to identify the what mistake on the script.
Please suggest.
Thanks,
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:54 AM
remove the try block keep the script only within onLoad function.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....