- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 11:24 PM
Hi,
We have requirement to copy the previous record field data to new record field.
For example - When a status report is created in project then "Senior Management Report" field should copy the data of previous status report "Senior Management Report" field of the same project automatically.
Please let me know if you need more details
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 11:33 PM
You can use a Before insert Business Rule. in this rule can be triggered when a new record (status report) is inserted, and it will copy the value from the previous record of the same project.
Use following code as reference:
(function executeRule(current, previous /*null when insert*/) {
// Make sure the project field is set in the current status report
if (current.project) {
var previousReport = new GlideRecord('status_report');
previousReport.addQuery('project', current.project);
previousReport.orderByDesc('sys_created_on');
previousReport.setLimit(1);
previousReport.query();
if (previousReport.next()) {
// Copy the "Senior Management Report" field from the previous record
current.senior_management_report = previousReport.senior_management_report;
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 11:33 PM
You can use a Before insert Business Rule. in this rule can be triggered when a new record (status report) is inserted, and it will copy the value from the previous record of the same project.
Use following code as reference:
(function executeRule(current, previous /*null when insert*/) {
// Make sure the project field is set in the current status report
if (current.project) {
var previousReport = new GlideRecord('status_report');
previousReport.addQuery('project', current.project);
previousReport.orderByDesc('sys_created_on');
previousReport.setLimit(1);
previousReport.query();
if (previousReport.next()) {
// Copy the "Senior Management Report" field from the previous record
current.senior_management_report = previousReport.senior_management_report;
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 02:57 AM
Hi @Community Alums
If we create a new status report without entering any text in the Senior Management Report field and click the save button, the previous record will become visible in the Senior Management Report field. The report should immediately display the text from the previous report when creating a new one, not just after saving.
Thank you