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

Scenario-Based Questions PART 36

🎓 Scenario-Based Question

 

📎 Use Case: Copy Attachment from One Table to Another

In this example, attachments added to an Incident are automatically copied to a related Problem record via a Business Rule.

Steps to Implement:

  1. ✅ Create a Problem record in the problem table and note its Problem Number.
  2. ✅ On the Incident form, add the Problem related list if missing:
    Incident Form > Configure > Related Lists > Add "Problem -> Parent"
  3. ✅ Create an Incident, fill required fields, save, and link the Problem number in the related list.
  4. ✅ Create a Business Rule on the incident table with these settings:
    • Name: (your choice)
    • Before Insert: ☑️
    • Advanced: ☑️

Business Rule 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);
  

Final Steps:

  1. Save the Business Rule.
  2. Attach a file to the Incident record you created and update it.
  3. Navigate to the related Problem record and verify that the attachment is copied there.

🎉 You’ve successfully automated attachment copying between Incident and Problem tables!

Comments

No comments yet.


Log in to post a comment