- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 01:41 PM
HI,
I am using a variable type attachment and user attach the documents and submit an incident. I have a script written on the record producer but seems it is not working. Can anyone please help me what wrong i am doing
var attachment = new GlideSysAttachment();
var incID = current.getUniqueValue();
var sysAttachGR = new GlideRecord('sys_attachment');
sysAttachGR.get("table_sys_id",incID);
var copiedAttachments = attachment.copy('sys_attachment', sysAttachGR.sys_id, current.getTableName(), current.sys_id);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 02:11 AM
Hi,
Please follow the steps below to achieve your requirement:
1) Couple of things to note here, when you add an Attachment in your custom variable of Type = Attachment, ServiceNow will not show them in the header of the record which you are expecting to be visible in the Attachment header on the Incident form.
Reason why: When ever you upload an Attachment using the Attachment Type variable all the files which gets uploaded in the Attachment table has a Table Name starting with "ZZ_Table Name".
For example :"ZZ_YYincident". Refer to screenshot below:
Now as per ServiceNow design below is the principle why it will not be shown:
"
ServiceNow automatically hides that attachment so that it only displays the contents in the form and doesn’t look like an image attached to the record. To do this, you have to:
- Go to the sys_attachment table
- Rename the "Table Name", appending the string "ZZ_YY" to the table name.
This is a convention that service-now uses to hide the attachment icon from the record for that image."
Refer to the HI Article below which confirms this:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0868420
Also one point to note here is you do not need a script at all for this scenario, as by default when ever you upload an Attachment, by default that gets visible in Activity Section of the record as shown below and user can access from there:
Refer to multiple screenshot with different file type:
This should resolve your query. Let me know if you have a follow up question on this.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 01:51 PM
Hello
Please find below articles you may find helpful
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0696061
Please mark answer correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 02:03 PM
I did gone through this article but i did not understand the resolution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 02:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 11:54 PM
Check sys_attachment table after submitting the record.
You'll see that attachment is created in table but with prefix ZZ_YY in table name.
This is why you don't see these attachments attached to records but you can see these in activity stream. Add "attachments" in activity stream and see if you can see the attachments.
If yes, then you can do something to remove the prefix OR you can copy the attachments using GlideSysAttachment.copy();
Here is an article about it.
ServiceNow Community Rising Star 2022/2023