Clear Comments field?

Robert_Cartwrig
Tera Expert

This question is not really specific to Risk.   Risk did not have the Comments and Activities fields, so I added them according to the instructions here: https://express.servicenow.com/support/forums/topic/can-you-add-a-journal-field-to-the-company-table...

This is pretty straightforward and works well enough - but the Comments field does not clear on Update and I cannot seem to make it do this thing.   The methods I've tried are mostly related to Business Rules to clear the field, but all attempts have failed. I am tired of beating my head against this wall.

I'm open to other suggestions about how to accomplish this seemingly simple thing.   Anyone?

Thank you,

Robert

1 ACCEPTED SOLUTION

I figured out what the issue was....or at least corrected it.   I double-checked the BR to clear it again, and nothing was wrong. What I hadn't checked was the other BR that was working - the BR that moved the content to the Activities journal.   It turned out that it was set to 200 as well...and it refused to be set to anything else.   I'd change it, and it would revert to 200.   I tried Insert and Stay. and saw the same behavior. So I deleted it and recreated it.   That worked...and allows the clear script to do its job as well.



Hate to mark my own answer as the correct one given all the great input on this thread (which were all correct, just not the issue), but I do want to close out this thread.


View solution in original post

13 REPLIES 13

amlanpal
Kilo Sage

Hi Robert,



Can you please post your codes? As per the link, which you have provided, it looks simple to write those 2 Business rules.


Hi Amlan,



As I mentioned, these Business Rules work.   The only issue I continue to have is that it doesn't clear the field on update.   I've tried Business rules using the selectors and Actions as well as a few versions of simple scripts (most of which I no longer have), and I've tried to add a conditional script directly to the Update UI Action (which I prefer not to do as it is global). I didn't post any of them as none were successful and I didn't want people to spend time troubleshooting my scripts when there might be a simpler solution available (and it should be easier to create this than troubleshoot my failures).



Script approaches that I've tried range from simple functions to directly setting the field.   Here are a couple of examples of my approach (these are written here and are not the actual exact script used):



-----------------------------------------


setClearComments();



function setClearComments() {


    if (!current.u_comments.nil())


          current.u_comments = " ";


------------------------------------------



or



------------------------------------------


setValue("u_comments", " ");


------------------------------------------



Conditions are usually simply that the field is not empty or even no conditions. I've tried before and after, on Update and both Insert and Update.   I've tried changing the order.   Before works, but this should happen after the text is saved, not before.



What am I doing wrong here?



Thanks,


Robert


Robert,



Enabled "Debug Business rule" and then update the ticket. check the logs to see if the business rules are passing. paste the logs here.



http://wiki.servicenow.com/index.php?title=Debugging_Tools_Best_Practices#gsc.tab=0


See attached...