Attachment mandatory when the field is appear on the change Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a requirement related to Risk Assessment and Change Management.
When a user submits the Risk Assessment, if they answer “No” to one of the questions, a follow‑up question is displayed. The value from that follow‑up question is then copied to the Change form (under the Planning tab).
Now, based on the value copied to the Change form (either Yes or No), we need to make attachments mandatory on the Change form.
We currently use a Business Rule to enforce the mandatory attachment requirement, and it mostly works.
However, there is one issue:
If the user adds an attachment before submitting the Risk Assessment, and then completes the assessment afterward, the field value on the Change form becomes “Yes” or “No”, but the Business Rule does not trigger because there is already one attachment on the form.
So the attachment requirement does not enforce correctly in this scenario.
How should I handle this situation so that the attachment is always mandatory when the field value is “Yes” or “No”, regardless of when attachments were added?
Please find the attached file for more details.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @MonikaRajuC , If the attachment is not mandatory to be attached or is it mandatory to be attached based on reply, what should happen when the answer is "no", do user will still have to add the attachment? and what will be the case for if "yes" is selected?
Regards,
Saurabh V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Saurabh,
Attachment have to be mandatory if the answer is yes or No. It is one hidden field (Name : Pre Production Testing). It will auto populate & Appear on Change form based on Risk Assessment Question. Once it will appear on Change Form Attachment have to be Mandatory.Before Risk Assessment the user attached any file it have to ignore again it have ask for attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@MonikaRajuC , Thanks for confirming back,
here is my proposed solution,
BR- when to run - insert & update.
Script -
(function executeRule(current, previous) {
var result = current.u_followup_result;
if (result == 'Yes' || result == 'No') {
var attachGR = new GlideRecord('sys_attachment');
attachGR.addQuery('table_name', current.getTableName());
attachGR.addQuery('table_sys_id', current.sys_id);
attachGR.setLimit(1);
attachGR.query();
var hasAttachment = attachGR.hasNext();
if (!hasAttachment) {
gs.addErrorMessage(
'error/info message'
);
current.setAbortAction(true);
}
}
})(current, previous);
Replace with your field name copied from Risk Assessment. This BR revaluates the form even when attachment is added earlier before answering yes or no.
If this response helped resolve your issue, please consider marking it as Accepted Solution and giving it a 👍.
This helps others in the community find useful answers more easily.
Regards,
Saurabh V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you Saurabh for your contributions. I tried one solution , hope it will work. Currently I'm doing testing . If I found any issue ,will replace my script with yours and will try.
Thanks,
Monika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
onSubmit Client script calling a script include that queries the sys_attachment table
depending on answer allow submission or abort
