Category: Scenario-Based Question PART 28
Updated on: August 12, 2025  |  0

Scenario-Based Question PART 29

๐ŸŽ“ Scenario-Based Question

ย 

Use Case: Prevent Incident Submission Without Attachment

We want to make sure a user cannot submit an Incident unless at least one file ๐Ÿ“Ž is attached to the form.


๐Ÿ›  Steps to Implement:

  1. Create a Business Rule
    • โœ… Active
    • โœ… Advanced
    • โœ… Before Insert
    • ๐Ÿ“„ Table: incident
  2. Write the script and save:
    (function executeRule(current, previous /*null when async*/) {
        var gr = new GlideRecord("sys_attachment"); 
        gr.addQuery("table_sys_id", current.sys_id);
        gr.query();
        if (!gr.hasNext()) {
            gs.addErrorMessage("๐Ÿ“Ž Attachment is required to submit this Request");
            current.setAbortAction(true);
        }
    })(current, previous);
          
  3. Test: Try to submit a new Incident without an attachment. Youโ€™ll see an โŒ error message, and the record wonโ€™t be created.

๐Ÿ’ก Pro Tip:

Instead of just blocking the submission, you can also guide users with a UI Policy to visually prompt them to attach a file before submission.

Comments

No comments yet.


Log in to post a comment