Work notes/Additional comments fields and activities are not visible on the incident form

Audumbar kamble
Tera Contributor

Hello Everyone,

Need help on the below issue, Work notes/Additional comments fields and activities are not visible on the incident form for admins as well but Caller can see the mentioned fields and activities.

 

There is ServiceNow KB for this issue - KB0855517 but as mentioned in second option I was checking audit table but there is no record found in 'sys_audit_relation' table for the affected incident.
Please find attached snapshot for a reference.

 

Thank you for you response in advance!!

10 REPLIES 10

Chaitanya ILCR
Mega Patron

Hi @Audumbar kamble ,

if it was I'm thinking it is

we also had similar issue and we got this from HI support they have provided a fix script 

Remove blank journal entries and all associated history sets. Removes sys audits, journal entries, and history sets. Removal is performed in chunks of 800 at a time, configurable by modifying the LIMIT constant.

A journal entry is considered to be blank if:
- It is empty
- It contains only whitespace characters
- It contains a single empty [code][/code] tag
- It contains a single [code][/code] tag containing only whitespace characters

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2139855

 

run this fix script and try if it fixes things

var LIMIT = 800;
var EMPTY_EXP = '^(\\[code]\\s*\\[/code])?$';

var SYS_AUDIT = 'sys_audit';
var SYS_JOURNAL_FIELD = 'sys_journal_field';

var TABLE_CONFIG = {};
TABLE_CONFIG[SYS_AUDIT] = {
    tableColumn: 'tablename',
    valueColumn: 'newvalue'
};
TABLE_CONFIG[SYS_JOURNAL_FIELD] = {
    tableColumn: 'name',
    valueColumn: 'value'
};

removeEmptyJournalEntries();

function removeEmptyJournalEntries(auditsComplete, journalsComplete) {
	var auditCount = auditsComplete ? 0 : removeChunk(SYS_AUDIT);
	var journalCount = journalsComplete ? 0 : removeChunk(SYS_JOURNAL_FIELD);

	if (auditCount === LIMIT || journalCount === LIMIT) {
		removeEmptyJournalEntries(auditCount < LIMIT, journalCount < LIMIT);
	}
}

function removeChunk(table) {
	return clean(
		collectChunkOfEmptyRecordIds(
			new Result(table),
			recordCreator(table)
		)
	);
}

function collectChunkOfEmptyRecordIds(result, createRecord) {
	collectEmptyRecordIds(result, createRecord("EMPTY"));

	if (result.size() < LIMIT) {
		collectEmptyRecordIds(result, createRecord("SPACE"));
	}

	if (result.size() < LIMIT) {
		collectEmptyRecordIds(result, createRecord("CODE"));
	}

	return result;
}

function collectEmptyRecordIds(result, record) {
	while (result.size() < LIMIT && record.nextValueIsEmpty()) {
		result.addSysId(record.getValue('sys_id'));
		result.addElementId(record.getValue('element_id'));
	}
}

function clean(result) {
    var size = result.size();

    if (size > 0) {
        var table = result.table;

        var tableCleaner = new GlideTableCleaner(table, 0);
        tableCleaner.setConditions('sys_idIN' + result.sys_id.join(','));
        tableCleaner.clean();

        if (table === SYS_JOURNAL_FIELD) {
            var historyCleaner = new GlideTableCleaner('sys_history_set', 0);
            historyCleaner.setConditions('idIN' + Object.keys(result.element_id).join(','));
            historyCleaner.clean();
        }
    }

    return size;
}

function recordCreator(table) {
	return function (type) {
		var config = TABLE_CONFIG[table];
		var record = new GlideRecord(table);

		if (table === SYS_AUDIT) record.addQuery('oldvalue', 'JOURNAL FIELD ADDITION');
		if (type === "CODE") record.addQuery(config.valueColumn, 'STARTSWITH', '[code]');
		if (type === "EMPTY") record.addEncodedQuery(config.valueColumn + "ISEMPTY^OR" + config.valueColumn + "=[code][/code]");
		record.orderBy(config.valueColumn);
		record.setLimit(LIMIT);
		record.query();

		return new Record(config, record);
	};
}

function Result(table) {
	this.element_id = {};
	this.sys_id = [];
	this.table = table;

	this.addSysId = function (id) { this.sys_id.push(id); };
	this.addElementId = function (id) { if (id) this.element_id[id] = true; };
	this.size = function () { return this.sys_id.length; };
}

function Record(config, record) {
	this.config = config;
	this.record = record;

	this.getValue = function (column) { return this.record.getValue(column); };
	this.nextValueIsEmpty = function () {
		return record.next() && (
			!this.record.getValue(this.config.valueColumn) ||
			this.record.getValue(this.config.valueColumn).trim().match(EMPTY_EXP)
		);
	};
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya