
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 07:44 PM
On insert or update of the form, if the field "submission_type" is "Client Change Request" I need the user to attach a document before being allowed to submit the form. Any ideas on how I can accomplish this? Examples will be great.
Thanks,
Edwin
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 08:41 PM
I believe hasAttachmensts() is not allowed in scope applications. Then remove the conditions and use this in the script
var gr= new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.getValue('sys_id'));
gr.query();
if(!gr.hasNext()){
gs.addErrorMessage("No attachments");
current.setAbortAction(true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 08:14 PM
Write a before business rule.
When: before insert
Conditions: !current.hasAttachments()
Script:
gs.addErrorMessage("No attachments");
current.setAbortAction(true);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 08:32 PM
I'm receiving the following error:
Function hasAttachments is not allowed in scope x_hemas_connectus2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 08:37 PM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (!current.hasAttachments())
{
gs.addErrorMessage('There is no attachment');
current.setAbortAction(true);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2016 08:41 PM
I believe hasAttachmensts() is not allowed in scope applications. Then remove the conditions and use this in the script
var gr= new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.getValue('sys_id'));
gr.query();
if(!gr.hasNext()){
gs.addErrorMessage("No attachments");
current.setAbortAction(true);
}