- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 02:27 AM
Can anyone provide UI action script to show list of attachments attached to the form. The functionality will be same as OOB paper clip attachment button present in every form but this ui action should not provide options to users to remove/add attachments. it will just show list of attachments and when clicked on attachment it should open so that user can read it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 02:34 AM - edited 10-26-2022 02:38 AM
Hi @Nikhil55 ,
For this you will have to modify your display BR and UI page both. Make the below mentioned changes :
1. Modify your display Business rule as shown below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var files = [];
var attachGr = new GlideRecord("sys_attachment");
attachGr.addQuery("table_sys_id",current.getUniqueValue());
attachGr.query();
while(attachGr.next()){
var info = {};
info.file_name = attachGr.getValue("file_name");
info.link = attachGr.getLink();
files.push(info);
}
g_scratchpad.filesUploaded = JSON.stringify(files);
})(current, previous);
2. Modify the UI page as shown below:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="attachments_uploaded">
</div>
<script>
var files = g_scratchpad.filesUploaded !="" ? g_scratchpad.filesUploaded : "";
files = JSON.parse(files);
var message = "";
ele = document.getElementById('attachments_uploaded');
//alert(files)
if(files != ""){
//var fileNames = files.split(",");
files.forEach(function(fName){
//console.log(fName)
message += "<a href ="+fName.link + " >" +fName.file_name + "</a>"+"<br/>";
})
}
//alert(message)
ele.innerHTML = message
</script>
</j:jelly>
I Hope this helps.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 02:34 AM - edited 10-26-2022 02:38 AM
Hi @Nikhil55 ,
For this you will have to modify your display BR and UI page both. Make the below mentioned changes :
1. Modify your display Business rule as shown below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var files = [];
var attachGr = new GlideRecord("sys_attachment");
attachGr.addQuery("table_sys_id",current.getUniqueValue());
attachGr.query();
while(attachGr.next()){
var info = {};
info.file_name = attachGr.getValue("file_name");
info.link = attachGr.getLink();
files.push(info);
}
g_scratchpad.filesUploaded = JSON.stringify(files);
})(current, previous);
2. Modify the UI page as shown below:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="attachments_uploaded">
</div>
<script>
var files = g_scratchpad.filesUploaded !="" ? g_scratchpad.filesUploaded : "";
files = JSON.parse(files);
var message = "";
ele = document.getElementById('attachments_uploaded');
//alert(files)
if(files != ""){
//var fileNames = files.split(",");
files.forEach(function(fName){
//console.log(fName)
message += "<a href ="+fName.link + " >" +fName.file_name + "</a>"+"<br/>";
})
}
//alert(message)
ele.innerHTML = message
</script>
</j:jelly>
I Hope this helps.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 12:25 AM
Hi @Nikhil55 ,
Is your issue resolved ? if yes, could you please help us close this thread by marking appropriate answer as helpul and accepting the solution.
This will help others having similar issue get proper solution.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 08:17 PM
Hi @Nikhil55 ,
This is a followup on your issue. Could you please help us close this thread by Accepting the solution, if your problem is solved.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2022 11:26 PM
Hi @kamlesh kjmar , Thank you for the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 10:14 PM
Hi @kamlesh kjmar can you please provide same script for workspace ui action also?