- 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
11-26-2024 02:14 PM
i will give this a shot and see what happens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 04:26 AM
Hi,
If your query is resolved, please mark the answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 04:42 AM
I had shared working solution for this 1 year ago
enhance for your requirement
Disable ZZ_YY prefix from attachment when added through record producer
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 12:57 AM
Hi @Ankur Bawiskar,
I have written Async insert BR to achieve the same, please guide me why it's not working for me.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here "ZZ_YY"
var gr = new GlideRecord("sys_attachment");
gr.addQuery("x_infte_intellectu_brandname_clearance", "ZZ_YY" + current.getTableName());
gr.addQuery("ca954dd0c3f83d102f7798bc7a013179", current.sys_id);
gr.query();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id);
}
})(current, previous);
Thank you in advance,
Amol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 02:49 AM
can you post a new question and tag me there as this is an older post?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader