When Incident work_notes is updated to empty string via script, Notes section disappears

Bharat Shinde
Tera Contributor

Hi Team,

 

When Incident work_notes is updated to empty string via script, Notes section disappears and shows No Activity.

 

inc.work_notes = "   ";

 

if you look at below image, there are activities..

BharatShinde_0-1753536623306.png

 

But when same incident is updated via script like below:

var inc = new GlideRecord('incident');

inc.addQuery('active',true);

inc.addQuery('number','INC02776931');

inc.setLimit(1 ) ;

inc.query();

if(inc.next()){

    inc.work_notes = "   ";

    inc.state = "2";

    inc.update();

    inc.setWorkflow(false);

}

BharatShinde_1-1753536766258.png


now it shows No Activity even though there are activates if I export the XML and i can found it there.


If i go to sys_journal_field table then i can see blank entry there but even i delete it or update it, still on Incident UI Notes section not loading.

How to fix it as we have multiple Incident records of same?

 

Regards,

Bharat 



5 REPLIES 5

SANDEEP28
Mega Sage

@Bharat Shinde Why are you updating empty string in work_notes ? what is the requirement here?

Hi @SANDEEP28 
I am not updating empty string, actually we have integration with third-party and they are sending in their payload while updating back the incident for other fields. We have inform them but i am not sure why ServiceNow behaving like this as we do not have control.

Bharat Shinde
Tera Contributor

Hi All,
it seems i found the solution for this:

I tried for one record on which Activity section was not showing, and following below steps I am able to see that section and activities back again.

Note* But this is manual and tedious process if there are too many incident record to fix by this way, this needs to perform first on non-prod environment and thoroughly verified.

Step 1: journal entry->
sys_journal_field.FILTER (ElementID=sys_id of incident record)
Need to delete the blank entry of work_notes from this table


Step 2: audit entry->
sys_audit.FILTER (DocumentKey=sys_id of incident record) - Remove OldValue and update NewValue
Need to delete the blank entry of work_notes from this table


Step 3: history entry->
sys_history_set.FILTER (ID=sys_id of incident record) - delete record from here
Need to delete the history record of that incident from this table

 

Reference Video:

How to update existing work notes/comments from a record in servicenow
https://www.youtube.com/watch?v=bcK8Ajdl5c4

 

JackieZhang
Tera Contributor

Actually I don't suggest to use table API directly for integration. You should try to use scripted rest API to restrict the dirty data like blank work_notes into ServiceNow.