Category: Scenario-Based Questions PART 31
Updated on: August 12, 2025  |  0

Scenario-Based Questions PART 31

🎓 Scenario-Based Question

 

📌 Use Case: Move Attachment from One Table to Another (Incident ➡️ Problem)

This scenario demonstrates how to automatically copy an attachment from an Incident record to its related Problem record using a Business Rule.


🛠 Steps to Implement:

  1. Create a Problem Record
    • Navigate to [problem] table
    • Fill in the Problem Statement
    • Copy the generated Problem Number
  2. Prepare the Incident Form
    • Add the Problem related list if not present:
      Incident Form → Configure → Related Lists → "Problem → Parent"
  3. Create an Incident
    • Fill mandatory fields & Save
    • In the Problem related list, link it to the previously created Problem Number
  4. Create a Business Rule
    • Table: incident
    • When: Before Insert ☑️
    • Advanced: ☑️
    • Script:
    (function executeRule(current, previous /*null when async*/) {
        var prb = new GlideRecord('problem');
        prb.addQuery('parent', current.getUniqueValue());
        prb.query();
        if (prb.next()) {
            var copyAtt = new GlideSysAttachment();
            copyAtt.copy('incident', current.getUniqueValue(), 'problem', prb.getUniqueValue());
        }
    })(current, previous);
          
  5. Test the Functionality
    • Attach a file to the created Incident
    • Update the record
    • Open the linked Problem record and verify the attachment has been copied

💡 Pro Tip:

 

  • Use GlideSysAttachment().copy() for quick file duplication between tables.
  • This approach works for any two tables, not just Incident and Problem.
  • You can modify the Business Rule condition to trigger only on specific scenarios (e.g., certain states or priorities).

 

Comments

No comments yet.


Log in to post a comment