attachmentHandler/snattachmentHandler doesn't work in scoped Applications

Murali krishna3
Mega Guru

Hi All,

I trying to replicate the ticket attachment widget for one of scoped application portal. I could see that attachmentHandlers is being used on OOB ticket attachment widget, when I tried the same on my scoped application widgets, it doesn't seem to work. 

Need help to figure out why it isn't working or any workaround for it. Any help is much appreciated. Here is my code,

HTML:

 <span class="file-upload-input">
<input type="file" style="display: none" name="grFile" id="grFile" multiple="true" ng-file-select="attachFile($files,$event)" class="sp-attachments-input">
<button ng-click="attachmentGRC($event)" type="button" class="btn btn-default send-message">${Add Attachment}</button>
</span>

Client script:

$scope.attachmentGR = function($event) {
$event.stopPropagation();
var $el = $element.find('input[id=grFile]');
$el.click();
}

$scope.attachFile = function(file,$event)
{
var e = $event.currentTarget;
if (e)
e.value = '';


snAttachmentHandler.create('sn_grc_issue', $scope.data._attachmentGUID).uploadAttachment(file[0]).then(function(response) {

snAttachmentHandler.renameAttachment(response.sys_id, fName).then(function(response) {
var nah = $scope.attachmentHandler = new nowAttachmentHandler(setAttachments, function() {});
nah.setParams('sn_grc_issue', $scope.data._attachmentGUID, 1024 * 1024 * 24 /*24MB*/);
function setAttachments(attachments, action)
{
$scope.attachments = attachments;
$scope.data.attachmentList = attachments;
console.log("attchlist0 = "+attachments)
}
$scope.attachmentHandler.getAttachmentList();
});

});
};

var ah = $scope.attachmentHandler = new nowAttachmentHandler(setAttachments, function() {});
ah.setParams('sn_grc_issue', $scope.data._attachmentGUID, 1024 * 1024 * 24 /*24MB*/);
// console.log("current target = " + fName);
function setAttachments(attachments, action)
{
$scope.attachments = attachments;
$scope.data.attachmentList = attachments;
console.log("attchlist = "+attachments)
}
$scope.attachmentHandler.getAttachmentList();
}

Thanks,

Murali Pasikanti

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Murali,

on which form you are trying to perform this?

what is your exact requirement here?

Did you try using OOB attachment paper clip icon for your requirement

Regards
Ankur

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