Copy Only Entered Comment from HR Case to HR Task and Vice Versa
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 07:51 AM
Hey All,
I am writing a script in HR Module to copy the additional comment from hr case to hr task and vice versa.
But my scripts aren't functioning as expected. From both the case the comments are getting populated but with an extra comment.
Say suppose If I comment in Case its getting populated in task but same comment is again getting added in case.
and If I comment in Task then its getting added in case but again that case comment which is copied is populating back in the task.
Case to Task:
var gr = new GlideRecord('sn_hr_core_task');
gr.addQuery('parent', current.sys_id);
gr.query();
if (gr.next())
{
if(current.comments.getJournalEntry(1).indexOf(gr.comments.getJournalEntry(1)) == -1)
{
var comment = current.comments.getJournalEntry(1);
gr.comments = comment;
gr.update();
}
}
Task to Case:
var comment = new GlideRecord('sys_journal_field');
comment.addQuery('name', 'sn_hr_core_task');
comment.query();
if (comment.next())
{
var gr = new GlideRecord("sn_hr_core_case");
gr.get(current.getValue("parent"));
gr.comments = current.number + " - " + comment.value.toString();
gr.update();
}
Any solutions for this or rather another way to accomplish this requirement.
Thanks In Advance!
0 REPLIES 0