Write Work Notes per Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2013 08:45 AM
Hello Community
Currently I try to Log a Message into this 'Activity' / Work Notes on a Requested Item / Tas
I copied a business rule that checks, if a request has a file attached, if it is, the file should be inserted into the Work Notes as a Link.
On the Wiki I found an interesting post that describes exactely what I want to achieve, but I don't get it to work. Don't get me wrong, I already found some articles with all the information I need to achieve this, my only problem is the Log into these work_notes doesn't work.
I tried the following approaches in the Business Rule:
setJournalEntry(current.comments, 'Manual Entry);
current.comments.setJournalEntry('Manual Entry);
current.work_notes.setJournalEntry('Manual Entry);
setJournalEntry(current.work_notes, 'Manual Entry);
current.update();
But no Log appeared, can anyone help me out there?
Thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2013 01:39 PM
You're missing the quote on the end of 'Manual Entry.
If this is a before update business rule, all you need to add work notes is:
current.work_notes = string_containing_desired_stuff;
It's possible you haven't got the work notes included in your activity display. If you manually type some work notes and save the record, can you see what you typed in the activities list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2013 04:35 AM
Hi geoffcox
Strange, in the code I had all the necessary quotes, so this shouldn't be the problem.
Yes it is a before update business rule, but the suggested code didn't work.
I also checked the activity display: If I enter a message manually it immediately appears in the Activity.
Settings of Business Rule:
When: before
Insert & Delete
Active & Client callable (last one maybe not needed)
Code of the Business Rule
if (current.operation() == 'insert') {
gs.log('new file inserted');
var s = 'Manual String';
current.work_notes = s;
current.update();
}
Any other ideas? Is there maybe a System Property to allow writing to the Activity Log by Scripts / Business Rules?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2013 01:32 PM
1. Are you certain that you added work notes to the activity display (can you see any work notes that you enter manually on the form)?
2. Are you certain you weren't doing an update rather than an insert (since you seem to be testing for insert only)? By the way, if you only want the rule to run on insert, then instead of adding the test in your code, you can just un-check the "update" box on the business rule.
You don't need to (and shouldn't) call update() if you are in a "before insert" or "before update" business rule. In fact, it could be weird to call update() if the insert() hasn't occurred yet (that may be your problem).
I tested the following before insert/update business rule on https://demo001.service-now.com/, on the Incident table. It might still be there if you look soon. 🙂
current.work_notes = "This is a test. GBC";
Following an update, the work note does appear in the comments/work notes area on the form.
Let me know if this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2013 12:55 PM
Had the same problem , WIKI has no examples for this. In case this helps anyone here is the solution that worked for me
current.[field name].setJournalEntry(current.[field name]); (EX - current.u_notes.setJournalEntry(current.work_notes);