<now-attachments-list template="sp attachment" />

MCH
Mega Contributor

Hello,

I used the widget 'Ticket Attachments' in Service Portal of Helsinki.

In this widget there is an element which call 'now-attachments-list'.

I want to understand what the meaning of this element, maybe it's a directive of angular? so, where it's defined?

I would be happy if someone can explain me what is it exactly.

thanks,

Michal

1 ACCEPTED SOLUTION

Michal,



I apologize that my answer was not clear. When I stated that it was on the ServiceNow side, I meant that it's not directly accessible to us. It's directly accessible to ServiceNow employees on their side. You won't find it under any Module, Angular Providers or dependency sections.


That said, it doesn't mean you can't get to it. With a closer look by doing an Inspection, you can see how the directive is defined.



Here is the directive script:



angular.module('sn.common.attachments').directive('nowAttachmentsList', function(getTemplateUrl) {


  'use strict';


  return {


  restrict: 'E',


  replace: true,


  templateUrl: getTemplateUrl("attachments_list.xml"),


  link: function(scope, elem, attrs, $parse) {


  scope.icons = {


  preview: attrs.previewIcon,


  edit: attrs.editIcon,


  delete: attrs.deleteIcon,


  ok: attrs.okIcon,


  cancel: attrs.cancelIcon


  };


  scope.listClass = "list-group";


  var inline = scope.$eval(attrs.inline);


  if (inline)


  scope.listClass = "list-inline";


  scope.entryTemplate = getTemplateUrl(attrs.template || "attachment");


  }


  };


});


;


View solution in original post

28 REPLIES 28

Can you provide xmls or an update set to get the full codes?

Hi @Edoardo Gattei ,

Sorry I don't have any of the updates saved. This post was done a few years ago.
However, all the pieces described here should be able to guide you through creating your own.

 

Hi @ChrisBurks,

at which point is the attachments object build which is itterated in the ng_repeat of attachments_list.xml?

Is it somehow possible to add attributes (e.g. a custom field from sys_attachment) to the attachment object?

where is the attachment object defined? can it be extended adding fields?

The attachment object is defined in the client controller of the attachment widget. You should find the "setAttachments" function. Inside that function you should see $scope.attachment.