c.server.get not working in service portals
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I have a requirement where user should get informational message if he is trying to attach a file of more than 3MB on a portal.
I'm trying to get this functionality done over a widget itself.
below are my client controller and server script.
Client controller:
function setAttachments(attachments, action) {
if (currentUrl == 'https://fjglobaldev.service-now.com/esc?id=fj_sc_cat_item&sys_id=17ec23d1db29a85892d8e03cd3961924' && action=='added') {
alert('action inside: '+action);
c.data.action = 'getGUID';
c.data.attID = $scope.data._attachmentGUID;
var id = c.data.attID;
alert("scoped: " + $scope.data._attachmentGUID);
alert('c.data.attID: ' + c.data.attID);
alert('size1: ' + $scope.data.size);
var inputs={
action: 'getGUID',
attID: id
}
c.server.get(inputs).then(function(response) {
alert('size: ' + $scope.data.size);
c.server.update();
});
}
$scope.attachments = attachments;
}
Server script:
Server script:
data._attachmentGUID = gs.generateGUID();
if (input && input.action == 'getGUID') {
data.final_size=0;
gs.log("input.attID: "+input.attID,'rohini');
var att = new GlideRecord('sys_attachment');
att.orderBy('sys_created_on');
att.addQuery('table_sys_id',input.attID);
att.query();
while(att.next()) {
data.size = att.size_bytes;
gs.log("data.size " + data.size, "rohini");
gs.log("Count1: " + att.getRowCount(), "rohini");
}
}
Now, I'm able to get size of attached of file on a server side in logs. but at the same I'm unable to fetch it on client side.
Now, I'm able to get size of attached of file on a server side in logs. but at the same I'm unable to fetch it on client side.
0 REPLIES 0
