The CreatorCon Call for Content is officially open! Get started here.

Attachment in Service Portal

Ashish Kumar Ag
Kilo Guru

When we attach in service portal before submitting request, its create a entry in attachment table with table name sp_portal and a sys_id for table_sys_id. But i couldn't trace the sys_id.

Any idea which sys_id its referring to?

Also suppose in a catalog request in SP you attach a file and then changes your mind to submit the request. So if i am not submitting the request how to delete that entry. Apart from user removes by clicking cross icon. pradeepksharma

10 REPLIES 10

ChrisB

 

"Once the catalog item is submitted the sys_id is swapped out with the RITM's sys_id along with the sp_portal table being switched out with the corresponding table."

This isn't working correctly for our instance.  We retrofitted attachments for Order Guides but the result is mixed.

Within this post:

$http.post(spUtil.getURL('sc_cat_item_guide'),{
"items": $scope.included, 
"sc_cat_item_guide": $scope.data.sys_id,
"_attachmentGUID":$scope.data._attachmentGUID
}).success(function(response) {
var a = response.answer;
var n = a.number;

If an admin submits the order guide with an attachment, the attachment is added to the sys_attachment table with the table name "sc_request" and the table sys_id is the same as a.sys_id.

If a non-admin submits the order guide with an attachment, the attachment is added to the sys_attachment table with the table name "sp_portal" and the table sys_id is the $scope.data._attachmentGUID.

Can anyone explain what's happening and why??  AND how can I fix it so that the attachments gets linked to the RITMs?

Seth

For me with admin access also, attachment stays in sp_portal table only,  facing this issue with .xlsm file type.

 

Any suggestion Sir?

Tim Woodruff
Mega Guru

I actually wrote an article on exactly this subject, called "Requiring Attachments (& Other Miracles) in Service Portal", on my site SN Pro Tips. This article contains a couple of scripts and example code that you can use to invoke it in your instance. At the bottom, you'll find a link to download an update set (for free) which contains all of the code mentioned in the article. 

http://attachments.snc.guru/

You might also be interested in another related article I wrote: Understanding Attachments in ServiceNow, or my Advanced Attachment Copy Util tool.

Nicely written articles.  Unfortunately it's not exactly what I'm looking for or I'm being dense.

Why would the functionality I have work for admins but not non-admins?  Non-admins can add attachments everywhere else, except on this code for Order Guides.

I tracked down my issue.  Updating the attachments using:

$http.put('/api/now/v2/table/sys_attachment/' + value.sys_id, data);

requires the admin role.  Any ideas on how to get around that and update the table_name and table_sys_id with using the API call?