additional comments are not captured when update filed values via business rules

hemanth810620
Tera Contributor
Issue: When manually updating the "state" field on the incident form, the changes are captured in the "Activities(additional comments- Field Changes)".
However, when the "state" field is updated programmatically based on conditions (via Business Rule), so the update changes are not captured in the "Activities(additional comments- Field Changes)".. 
 
Issue: When manually updating the 'state' field in the Incident form, the changes are correctly captured in the Activities(additional comments- Field Changes). However, when the 'state' field is updated based on conditions (e.g., via business rules), the update is not reflected in the Activity Logs or Comments section. The changes are being successfully applied to the record, but no log entry is created, leading to incomplete tracking of changes.
 
Impact: This causes incomplete logging in the Activity Log and makes it difficult to track changes made programmatically.
 
Expected Behavior: Changes to the "state" field should be logged in the Activity Log regardless of whether they are made manually or programmatically.
 
Steps to Reproduce:
1. Update the "state" field manually - logs are captured in Activities(additional comments).
2. Update the "state" field programmatically using a script condition - Activities(additional comments) are missing.
 
BR Script:
 
When = additional comments --> Changes
 
(function executeRule(current, previous /*null when async*/ ) {
    // Check if a comment was added
   // if (current.comments.changes()) {}
        // Verify if the comment is from the requester (opened_by)
        if (current.opened_by == gs.getUserID()) {
            // Check if the state is Resolved (assuming states)
            if (current.state == 6 || current.state == 3 || current.state == 4 || current.state == 5 || current.state == 😎 {
                // Reopen the incident by setting the state to Active (2)
 
                current.state = 2;
current.short_description="testing--";
current.setWorkflow(false);
                current.update();
 
                current.setWorkflow(true);
            }
        }
    
})(current, previous);

 

7 REPLIES 7

Brad Bowman
Kilo Patron
Kilo Patron

There is another Business Rule that is adding the field changes to the activity log.  Your Business Rule shown above has 

current.setWorkflow(false);

Which instructs that no other Business Rules should run when this record is updated.  Remove this line and re-test.

 

When i removed this line (current.setWorkflow(false);
comments got updated.. Thank you 
But current.update(); is good practice to update record? 

Based on your Business Rule script, it looks like this should be running before insert/update, then you can remove the current.update(); line.  If you must run the Business Rule after update for whatever reason, then current.update() is fine to save the changes to the fields.

hemanth810620_0-1734064969080.png

I written after business rules 

comments got updated multiple times..