Latest attachment not visible on the request after removing ZZ_YY from attachment name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 06:49 AM
Hi Everyone,
I have a requirement of making attachment mandatory based on the value(Select-box) in one of the catalog item. So, instead of generic attachment(paper clip icon) I have used attachment variable in catalog item. Please refer below image for the variable
Whenever I upload the attachment and submit the form and the attachment would be named with prefix "ZZ_YY".
So, to avoid this I have used After insert BR and wrote a script like this
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
}
})(current, previous);
There will be no issue if I attach/upload a proper file for the first attempt in the variable but incase If I want to update the file in attachment variable using upload option and submit the form.
I am able to see the previously attached file not the latest one in request form.
Can anyone please help on this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 08:23 AM
Hi @Sampathr382
What is the reason to rename the table name in attachment record in the first place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 08:40 AM
Hi @Swapna Abburi
I need to rename the attachment table name since the attachment table name is prefixed with "ZZ_YYsc_req_item", since the attachment is not visible on the form.
So, I have added the gr.orderByDesc('sys_created_on'); query and it worked.
Anyway thanks for the response!!