
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2018 12:59 PM
I need to check if a record has an attachment onSubmit in ServicePortal with the out-of-box form widget. When using g_form.getSysId in a client script, it is returning -1. g_form.getUniqueValue() returns -1 as well.
g_form.getUniqueValue() works in CMS.
My GlideAjax seems to be working. I'm just having trouble getting the sys_id for the record to send as a parameter.
Any advice will be much appreciated.
Thanks,
Chris
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2018 12:42 AM
HI,
Below code will work for you:
if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please attach the requested laptop desktop template before submitting.');
return false;
}
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2018 01:08 PM
Can you check, when you attach the record, if you see a record in sys_attachment table and what is the table sys id?
Also how are you creating record in service portal?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2018 01:54 PM
Yes, when I add an attachment it creates a record in sys_attachment, has the correct table and has an entry for the record sys_id. If I submit the record the sys_ids match (the one for the submitted record and the sys_attachment entry).
The record is created on a custom page with the OOB form widget. It's accessed by URL with sys_id=-1 to submit a new record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2018 07:26 PM
I am not sure if you can get the sys_id.
Another option you can try is using current.hasAttachments() in a business rule. And if it returns false, do a current.setAbortAction(true);
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2018 12:42 AM
HI,
Below code will work for you:
if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please attach the requested laptop desktop template before submitting.');
return false;
}
Thanks,
Ashutosh Munot