Made a custom widget for 'Add attachment' on a service catalog but facing issue in viewing those.

Apps10
Tera Contributor

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&colon;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

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Apps10 

any reason for custom widget when you can use the OOB attachment icon or attachment type of variable?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,
yes custom widget is required only because the oob attachment is not providing functionality which is needed.
That's why.

thanks

Hi Ankur,
on production env it is throwing some error.

that's why used custom widget after discussions.

Hi Ankur,
Can you please help me in it.
Thanks