How to acces the images in the portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2025 08:48 PM
Hi guys , I got an requirement from my team where I want to upload images to the servicenow and the members of that organisation can fetch those images and videos through service now portal , and those images and videos should be downloadable , please help to configure this problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2025 09:26 PM
what's the business requirement for them to access and download?
you can upload images & videos to db_image & db_video table
check this link
How to add a video to a Portal page
check this video
https://www.youtube.com/watch?v=e-Twv_I7l7I
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-16-2025 09:27 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-19-2025 04:06 AM
I want to create a image liberary widget where input the user name and the data get fetch , i m doing this but my code isnt working it showing no images again and again
html
<div class="container bg-light p-3 rounded">
<div class="row mb-3">
<div class="col-md-12">
<input type="text" class="form-control mb-2" placeholder="Enter User Name" id="test">
<button class="btn btn-primary float-end" ng-click="loadUserImages();">Load Images</button>
</div>
</div>
<div ng-if="data.initialSearch && data.noFiles" class="alert alert-danger text-center">
ā No images found.
</div>
<div class="text-end mb-2" ng-if="!data.noFiles">
<button class="btn btn-success" ng-click="c.downloadAll()">ā¬ļø Bulk Download All</button>
</div>
<div class="row">
<div class="col-md-3 mb-3" ng-repeat="file in data.files">
<div class="card p-2 text-center shadow-sm">
<img
ng-click="c.togglePreview(file)"
ng-src="/api/now/attachment/{{file.sys_id}}/file"
class="img-thumbnail mb-2"
style="width: 60px; height: 60px; object-fit: cover; cursor: pointer;"
alt="{{file.name}}"
>
<h6 class="mb-1">{{file.name}}</h6>
<small class="text-muted">Uploaded on {{file.uploaded_on}}</small>
</div>
</div>
</div>
<!-- Image preview overlay -->
<div class="preview-overlay" ng-if="c.previewFile" ng-click="c.closePreview()">
<img
ng-src="/api/now/attachment/{{c.previewFile.sys_id}}/file"
class="preview-image"
alt="{{c.previewFile.name}}"
>
<div class="preview-close">Click anywhere to close</div>
</div>
</div>
client script
server script
(function() {
data.files = [];
data.noFiles = true;
data.initialSearch = true;
if (input && input.username) {
var username = input.username.toLowerCase();
var gr = new GlideRecord('u_u_drive_files');
gr.addQuery('u_uploaded_by.user_name', username); // dot-walk into reference field
gr.query();
while (gr.next()) {
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_name', 'u_u_drive_files');
attach.addQuery('table_sys_id', gr.getUniqueValue());
attach.query();
while (attach.next()) {
var name = attach.getValue('file_name');
var ext = name.split('.').pop().toLowerCase();
if (["jpg", "jpeg", "png", "gif", "webp"].includes(ext)) {
data.files.push({
sys_id: attach.getValue('sys_id'),
name: name,
uploaded_on: gr.getDisplayValue('sys_created_on'),
uploader: gr.getDisplayValue('u_uploaded_by')
});
}
}
}
data.noFiles = data.files.length === 0;
}
})();