Accessing a sys_attachment (Table Name = ZZ_YY<table name>) using sys_attachment.do?sys_id=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2021 11:27 AM
I have added a new field to the Knowledge Article table (kb_knowledge) which is of type "Image" so that an animated gif can be attached to a knowledge article. Apparently, the image is stored in the sys_attachment table.
We have configured our SN instance so that kb articles can be made public (i.e., a login is not required to view the article).
I have cloned some of the knowledge base widgets to display the image (Knowledge Results and Knowledge Article Content). I am using the following HTML code to display the image when a user is not logged in:
<span><img class="kb-thumbnail" alt=" " ng-src="https://<SNinstance>/sys_attachment.do?sys_id=<sys_attachment.sys_id>&view=true"/></span>
When viewing the article via the Service Portal, the image is not being displayed and I have tracked down the problem which seems to be that the "Table name" associated with the sys_attachment record is ZZ_YYkb_knowledge.
If I rename the Table Name to "kb_knowledge", I am able to display the image via the Service Portal via sys_attachment.do?sys_id=.
I have created a Business Rule to change the sys_attachment Table Name from "ZZ_YYkb_knowledge" to "kb_knowledge" when an image is attached to a kb article. All seems to be working (with the exception that the image is now showing up as an attachment, but I can live with that).
I was just wondering.....is there is a better solution?
TIA,
Liz
- Labels:
-
Knowledge Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2021 01:48 PM
Hi,
Due to this edge case scenario where you actually want the attachment to show on the record (aka it has to be there for the gif to show on the article), removing that prefix is the correct way to adjust that. The prefix ZZ_YY is added to hide the attachment from the record itself (as listed as an attachment). Documented here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0868420#:~:text=ServiceNow%20...
But because you are using this in a public manner, removing the prefix, helps making it show for the user.
So this would be the best solution for your situation.
And by using that business rule, you can automate that so it's not a manual process.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 09:57 AM
Hi,
Thanks for marking my reply as Helpful 🙂
If it also helped guide you correctly, if you don't mind, please also mark as Correct.
Thank you!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!