- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:26 AM - edited 06-30-2023 03:26 AM
Hello everyone,
I would like to copy work notes from demand to project.
Can you help on this topic.
I created a before BR :
Table : dmn_demand
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('pm_project');
gr.addQuery('demand', current.sys_id);
gr.query();
while (gr.next()) {
if(gr.comments.getJournalEntry(1).indexOf(current.comments) == -1 && gr.work_notes.getJournalEntry(1).indexOf(current.work_notes) == -1) {
gr.work_notes = current.work_notes;
gr.comments = current.comments;
gr.update();
}
}
})(current, previous);
FF
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:46 AM
Hi @Farfara
You should be retrieving the latest value for work notes and comments in current record too
Test with below code
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('pm_project');
gr.addQuery('demand', current.sys_id);
gr.query();
while (gr.next()) {
if (gr.comments.getJournalEntry(1).indexOf(current.comment.getJournalEntry(1)) == -1 && gr.work_notes.getJournalEntry(1).indexOf(current.work_notes.getJournalEntry(1)) == -1) {
gr.work_notes = current.work_notes.getJournalEntry(1);
gr.comments = current.comments.getJournalEntry(1);
gr.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:46 AM
Hi @Farfara
You should be retrieving the latest value for work notes and comments in current record too
Test with below code
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('pm_project');
gr.addQuery('demand', current.sys_id);
gr.query();
while (gr.next()) {
if (gr.comments.getJournalEntry(1).indexOf(current.comment.getJournalEntry(1)) == -1 && gr.work_notes.getJournalEntry(1).indexOf(current.work_notes.getJournalEntry(1)) == -1) {
gr.work_notes = current.work_notes.getJournalEntry(1);
gr.comments = current.comments.getJournalEntry(1);
gr.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:47 AM - edited 06-30-2023 03:49 AM
Hi @Farfara
Can you explain in detail of your requirement?
This works :
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('pm_project');
gr.addQuery('demand', current.sys_id);
gr.query();
while (gr.next()) {
gr.work_notes = current.work_notes;
gr.comments = current.comments;
gr.update();
}
})(current, previous);
Are you are syncing up from demand to project and vice versa too? Refer below link - https://www.servicenow.com/community/now-platform-articles/copy-task-comments-and-worknotes-to-paren...
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP