- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:37 AM
Hi,
I have the field 'Attachment Added' of type True/False. I need to mark this field as True, if attachment is added to the incident form.
How can I achieve that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:49 AM
Hi Alon,
You could have a before insert business rule on the attachment table.
1. GlideRecord the incident table to query the incident number
2. While loop through the records to check if the worknotes contains "Attachment: " + current.file_name + " has been attached.";
3. set gr.attachment_added = true;
4. gr.update;
Let me know if this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:49 AM
Hi Alon,
You could have a before insert business rule on the attachment table.
1. GlideRecord the incident table to query the incident number
2. While loop through the records to check if the worknotes contains "Attachment: " + current.file_name + " has been attached.";
3. set gr.attachment_added = true;
4. gr.update;
Let me know if this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:49 AM
Hi Alon,
Check the solution on this thread.
Solved: Update field based on attachment - ServiceNow Community

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:50 AM
Hi @Alon Grod ,
I checked your problem in my PDI and it works for me
I created onLoad Client script and aaded below code
function onLoad() {
//Type appropriate comment here, and begin script below
alert("getUniqueValue" + g_form.getUniqueValue());
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "incident");
gr.addQuery("table_sys_id", g_form.getUniqueValue());
gr.query();
if(gr.next()){
g_form.setValue('u_isattachmentadded', true);
g_form.update()
}
}
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 02:24 AM
I wouldn't recommend GlideRecord in a client script.