
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 06:42 AM
Hi all,
I found this article to copy task comments to the requested item: Copy Task Comments into Request Item History
What I have been asked to do is copy any work notes/comments from the project task to the parent project.
I've create a business rule, that does fire, but the information is NOT being transposed to the project. My ultimate goal is to get the work notes and comments from the task into the Activity area of the parent Project
gs.log('comment: ' + current.comments);
gs.log('wn: ' + current.work_notes);
var gr = new GlideRecord('pm_project');
gr.addQuery('sys_id', current.top_task.sys_id);
gr.query();
while (gr.next()) {
gr.setValue('comments',current.comment);**
gr.setValue('work_notes',current.work_notes);**
gr.update();
}
**again, I'd like these to appear in the Activity area of the parent project
Any help is greatly appreciated-
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 08:34 AM
Here you go. Use this code in after business rule on project task table
When: after insert5 and update
Conditions Additional Comments Changes OR Work notes changes
Script:
var gr = new GlideRecord('pm_project');
if(gr.get(current.getValue('top_task'))){
if(current.comments.changes())
gr.comments=current.comments.getJournalEntry(1);
if(current.work_notes.changes())
gr.work_notes=current.work_notes.getJournalEntry(1);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2018 04:23 AM
Hi Richelle,
Did you ever find a way of adding the task number to this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2018 04:35 AM
Did you just try it with the script? I don't have any changes to it, but I am getting the result:
If you tried it with just the script and it's not working, I can search around to hunt down what I did to get that bit of HTML to write to the parent Project. Alas, I'm afraid I don't remember everything I did last week...9 months ago is definitely a stretch. Thought I'm sure it's in the brain somewhere.
Thanks,
Richelle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2018 04:49 AM
Thanks for the quick reply Richelle. I've got it to display the work notes but there is no reference as to where it has come from. If you can remember how you did it that would be fantastic.
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2018 09:41 AM
Ah, I have found the answer. It is a client script on the Project Task (pm_project_task) table. I can't remember where I found it, but I am not taking credit for writing it...
Name: Tag Work Notes
Type: On Submit
Global: True
Order: 55
Script:
function onSubmit() {
var workingnote = gel('pm_project_task.work_notes');
if (workingnote == null) {return true;} //when work notes is read-only
if (workingnote.changed) { //on execute this if work notes field actually changes
var currentuser = g_user.firstName + " " + g_user.lastName; //build name
var tasknum = g_form.getValue("pm_project_task.number"); //get current task number
var storage = g_form.getValue("pm_project_task.work_notes"); //stores current typed in text
var baseURI = top.location.href.toString().split("/");
var url = "https://" + baseURI[2] + "/" + g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue();
var work_note = storage + "[code]\n\n<strong> Work note made from ";
work_note += "<a class='web' href='" + url + "' target='_blank'>" + tasknum + "</a></strong>[/code]";
g_form.setValue("pm_project_task.work_notes", work_note);
return true; }
return true;
}
I hope that helps,
Richelle