Made a custom widget for 'Add attachment' on a service catalog but facing issue in viewing those.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 11:41 PM
Hello All,
I have made a custom widget for 'Add attachment' on service catalog but there is a issue I am facing that the attached items I am not able to view on catalog item view but can be viewed on RITMs.
I want to view those attached items on cat item view also. Below are the script given.
Please let me know how can I achieve this.
HTML:
<div ng-bind-html="::data.html"></div>
<div>
<span class="file-upload-input">
<input type="file" style="display: none" multiple="true" ng-file-select="parent.attachmentHandler.onFileSelect($files)" class="sp-attachments-input">
<a href="javascript:void(0)" id="attachment_add" ng-click="parent.attachmentHandler.openSelector($event)" class="btn btn-primary sp-attachment-add">
<span class="glyphicon glyphicon-paperclip"></span>
<span ng-bind-html="::data.buttonCaption" style="padding-left: 10px"></span>
</a>
</span>
</div>
server side:
(function() {
data.html = "";
data.buttonCaption = gs.getMessage("Attachment_Button_with_HTML.Caption.AddAttachments");
if(options){
if(options.ui_message_key){
data.html = gs.getMessage(options.ui_message_key);
}
if(options.attachment_button_caption_key){
data.buttonCaption = gs.getMessage(options.attachment_button_caption_key);
}
}
})();
client controller:
api.controller = function($scope, $sce) {
var c = this;
$scope.data.html = $sce.trustAsHtml($scope.data.html);
$scope.parent = getParent($scope);
};
function getParent(parent) {
if (parent.item) {
return parent;
} else {
if (parent.$parent){
return getParent(parent.$parent);
} else {
//console.warn('Was not able to find parent widget');
}
}
}
Thanks
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 11:59 PM
any reason for custom widget when you can use the OOB attachment icon or attachment type of variable?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 12:08 AM
Hello Ankur,
yes custom widget is required only because the oob attachment is not providing functionality which is needed.
That's why.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 12:17 AM
Hi Ankur,
on production env it is throwing some error.
that's why used custom widget after discussions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 01:42 AM
Hi Ankur,
Can you please help me in it.
Thanks