🎓 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:
- Create a Problem Record
- Navigate to
[problem]
table - Fill in the Problem Statement
- Copy the generated Problem Number
- Navigate to
- Prepare the Incident Form
- Add the Problem related list if not present:
Incident Form → Configure → Related Lists → "Problem → Parent"
- Add the Problem related list if not present:
- Create an Incident
- Fill mandatory fields & Save
- In the Problem related list, link it to the previously created Problem Number
- 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);
- Table:
- 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).