The CreatorCon Call for Content is officially open! Get started here.

setJournalEntry not working correctly, in many ways

yvan
Tera Contributor

setJournalEntry is behaving inconsistently for us when running a script that mass closes and appends a journal entry to a chosen list of tasks; at times it will work correctly, at others we are seeing three incorrect behaviors for setJournalEntry:

  1. No entry appears at all in Activities, but does appear in sys_journal_field
  2. The string value provided for the Username is ignored and username of user that ran the script is entered instead.
  3. Entry is shoehorned somewhere in the middle of the Activity, with a user and timestamp associated with Update 0 in the History List, instead of the correct information in the sys_audit table

We are setting setUseEngines to false to prevent some of our automated behaviors from occurring instead of setWorkflow, as setJournalEntry doesn't even work when we use setWorkflow. 

 

EDIT/UPDATE

After some additional investigation the sys_audit table shows the correct information for all of the edited tasks.
However the Activity stream and History List are showing completely erroneous information.

Original script was run in a subprod and all tested tasks looked perfect there. Only after running this in production instance did things go completely sideways.

8 REPLIES 8

Brent Sutton
Mega Sage

Hi Yvan,

If you are setting the Journal Entry (sys_journal_field) directly then it probably won't show up in the activity stream of the ticket. I believe the activity formatter takes its information from another table (think its sys audit table but could be wrong) so setting it directly does not create an entry in this table.

You will get a full set of entries if you update the journal field directly in the ticket itself i.e. current.work_notes = "Your relevant comment";

Hope this helps,

Brent

I was under the impression that setJournalEntry was meant to emulate entering information manually, the script is meant to mass close 1000+ tasks, so manually entering a work note wouldn't really work for us.

yvan
Tera Contributor

After some additional investigation the sys_audit table shows the correct information for all of the edited tasks.

However the Activity stream and History List are showing completely erroneous information

Hi Yvan

I believe the activity formatter takes information from a number of tables to display on the ticket. A quick search suggests the activity formatter uses the following tables - Sys Audits [sys_audit]History [sys_history_line], and Record History[sys_history_set].

It will be hard to retroactively populate all these tables with the correct information.

Probably best to clear the slate and start again.

Brent

P.S. If you found this information useful then please mark as Helpful.