Modify Comments via Business Rules

mauricio23
Mega Expert

Greetings!

We have a field, Comments", which is a journal field type. I would like to be able to modify the comment before it gets submitted.

The goal is to make an entry in the first line that says: "From: username";

function onBefore(current, previous) {

  tag_comments();

  function tag_comments() {

  current.comments = "From: " + current.sys_updated_by;

  }

}

However, my business rule is "appending" this line. How can I pre-pend this line into the comments?

first_line.png

4 REPLIES 4

cwilkerbb
Giga Expert

It looks like "Notes entered in from the GUI" might be custom.   I don't think that's standard.   I'd check for a higher order Business Rule and either change the order to something greater than your "From:" Business Rule (something like 200 vs 100 which is probably is currently) or add your "From:" in that Business Rule.



Alternatively, you could just add "Updated By" to the Activity feed and that would accomplish the same thing.



-Chris


"notes entered in from GUI" is not triggered by a business rule.



It's input into "External Notes" text box which is right above it. It's basically our "comments" field. I will check on order to see if that helps.


Mike Allen
Mega Sage

Weird, your code works for me in my dev instance.  



Capture2.PNG



Capture3.PNG



Capture.PNG


hmmm - maybe it's an order issue - i'll look into that.