Business Rule duplicating comments

ben_kahn
Kilo Expert

Hi all, several of my technicians have requested a feature that would allow them to set a signature that would appear automatically when they update Incidents. We had this functionality in our old ticketing system and our people like to have a friendly and human touch when talking with our customers.

 

Anyway, to set this up, I just created two new fields on the user table, one to hold a signature and one to toggle it on or off. I am now trying to use a Business Rule to insert the signature after comments. Sounds easy enough, right?

 

Anyway, for some reason the comment itself is repeating after the signature is inserted. For example, say my signature is '- Ben, Field Tech' and I make a comment on an Incident that says "All done - I fixed the computer. Have a great day!". What shows up in the activity feed is:

 

 

All done - I fixed the computer. Have a great day!

 

- Ben, Field Tech

All done - I fixed the computer. Have a great day!

 

The code the business rule runs is just:

 

current.comments += "\n\n" + userSignature

 

Any ideas why it's doing this or how I can fix?

 

Thanks!

1 ACCEPTED SOLUTION

ben_kahn
Kilo Expert

I ended up solving this by creating a Business Rule to run on Display and pass the UserSignature values to the session in the g_scratchpad object.



I could then use a client script (instead of a Business Rule) to insert the Signature on Insert of the Incident.


View solution in original post

13 REPLIES 13

Mark Stanger
Giga Sage

Is the business rule running before the insert/update?


Mark, yes. The Business Rule is set to run before on update.



If I set after, display, or async nothing happens (no signature is appended to the comment).


Hi Ben,


       


                      It seems the problem occurring with concatenation.


Can you try this below code


Usersignature = 'Ben, field tech';


Urcomments = 'All done - I fixed the computer. Have a great day!';


Current.comments = usersignature+'\n'+Urcomments;



Regards,


Harish.


Anurag Tripathi
Mega Patron
Mega Patron

Hi Ben,



"current.comments += "\n\n" + userSignature" --> this is where i suspect the issue is. I think you are assuming that current.comment will have the value "ben, field tech" and you just concatenating the signature to it.



what you need to do is get the comment in some variable or something and then add it to comments in 1 go.



current.comment = "ben, field tech" +"\n"+ userSignature ;


-Anurag