Check the attachment when resolving the incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 07:10 AM
Hello Community Experts,
Could you please help me the coding snippet to check the attachment is added or not when resolving incident, If there is no attachment don't allow anything. We are looking for the on submit client script through glide Ajax.
Thanks,
Nagesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 07:32 PM
Thanks for your time to provide above script and unfortunately it's not working. May I know where did you calling hasattachment() function in client side?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 02:11 AM - edited 08-12-2024 02:12 AM
You are right, there is a slight error in this script,
In case You should use business rules instead of include scripts...
Because using a Before Update Business Rule can be a more robust approach for handling validations like checking attachments before updating a record. This method ensures that the validation occurs on the server side, which can be more reliable and less dependent on client-side interactions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 08:10 PM
you can use before update BR instead of glideajax
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(!current.hasAttachments()){
gs.addErrorMessage('Please add file before resolving');
current.setAbortAction(true);
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 08:44 PM
Thanks for the response and we can achieve through BR,But we are looking for glide Ajax on submit client script to display pop up message. Can't we achieve through glideAjax,If yes could you please provide code snippet?
Thanks,
Nagesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2024 09:49 PM
yes you can but if it can be achieved using BR I will recommend that.
using onSubmit + GlideAjax will require you to use synchronous GlideAjax so that it waits till the response comes from server side.
what did you debug in the above script include based approach?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader