Attachments are not visible on custom widget on catalog item view.

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

3 REPLIES 3

Community Alums
Not applicable

Hi @Apps10 ,

This issue can occur if angular provider "spAttachmentManager" is missing on custom form widget.

Resolution


  1. Navigate to custom Form widget.
  2. Scroll down to related list. 
  3. Find "Angular Providers" 
  4. Click on Edit 
  5. Add "spAttachmentManager
  6. Save and test 

OR,

  • When you add attachment while submitting the catalog item, an corresponding entry in sys_attachment table is made.  This entry suppose to point to the custom requested item table name. But it was pointing to standard requested item table sc_req_item.  
  • Due to this reason the attachment is not visible. 

So,Write a custom logic (before insert/update business rule on the custom requested class table) to update the sys_attachment record's table_name to the corresponding custom requested item table name instead of sc_req_item.

 

Hello Sandeep,
Thanks for the reply.

spAttachmentManager I have already provided it but still no luck.

 

Thanks

Hello Sandeep,
Could you please help me with the logic(BR).
Thanks