Monitor empty MRVS rows

Max_
Mega Contributor

Hello community members,

In our production instance we have an issue where sometimes empty rows are created thru a catalog item wit a multi row variable set. Mostly this goes well, just in some situations the rows are empty. We have not yet been able to reproduce, so thinking it could help if we would be notified more quickly on this behavior. Than we can look at logging, contact the user for what they did. Hoping this will help us in understanding and finding steps to reproduce.

Any thoughts on how we can monitor this? We are thinking of a report, a counter on a homepage, a notification, an incident, something like that. How to check if a row is empty created?

find_real_file.png(the bottom rows in the image are the empty rows)

Thank you.

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Just had a look in our instance, somehow we look to have similar behavior. Which we did not know of until now!

All answers on the variables from the multi-row-variable-set, are stored in the sc_multi_row_question_answer table. My thought would be to query this table, upon submitting the Catalog Item, so actually the inserted Requested Item. Because it's about empty rows, and not empty variables, I think you need to do multiple querying.

1) On insert of the sc_req_item, query the mrvs answer table on records for the parent sc_req_item
2) Group those results, so you would only be left with the unique rows
3) Query on those rows, if there are no values in any of the variables for that row OR turn it around, if there is at least one variable with a value (then the row is not empty)
4) Generate an event which could trigger a notification
5) Setup the notification

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

15 REPLIES 15

Looking at the table structure for sc_multi_row_question_answer, you would need to query on these fields:

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you for your respone.
Did you find a way to reproduce this behavior?

Max

No unfortunately. Will look into that later more in detail, if we do find a way I will share. For now I have worked on a aSync Business Rule, on insert of sc_req_item. Which basically queries the answer table for rows belonging to the just inserted sc_req_item. Those rows then are queried for all there records, if they contain a value. If not... empty row detected!

(function executeRule(current, previous /*null when async*/) {

// 	For debugging, sleep which gives you 30 seconds to manipulate inserted sc_multi_row_question_answer records
// 	gs.sleep(30000);
	
	var rowsArr = [];

	var gaMRVSAnswerRow = new GlideAggregate('sc_multi_row_question_answer');
	gaMRVSAnswerRow.addQuery('parent_id', current.getUniqueValue());
	gaMRVSAnswerRow.addAggregate('COUNT');
	gaMRVSAnswerRow.groupBy('row_index');
	gaMRVSAnswerRow._query();

	while(gaMRVSAnswerRow._next()) {
		rowsArr.push(gaMRVSAnswerRow.row_index);
	}
	rowsArr.join();

	for(var i = 0; i < rowsArr.length; i++) {
		var grMRVSAnswerValue = new GlideRecord('sc_multi_row_question_answer');
		grMRVSAnswerValue.addQuery('row_index', rowsArr[i]);
		grMRVSAnswerValue.addNotNullQuery('value');
		grMRVSAnswerValue.setLimit(1);
		grMRVSAnswerValue._query();

		if(!grMRVSAnswerValue.hasNext()) {
			gs.eventQueue('sqn.ritm.mrvs.empty_rows', current, '', '', '');
			break;
		}
	}

})(current, previous);

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

What is the debugging statement mentioned? Guess this is for testing purposes, though what is your thought with this one? I just see a gs.sleep 🙂

Max

Ah good one!
I've done this indeed to test the Business Rule. When submitting the Catalog Item (and therefor creating the sc_req_item and triggering the Business Rule), with this there's N seconds of time (in this case 30) to look for the question answer records in the sc_multi_row_question_answer table. The value for all records belonging to the same row_index for the sc_req_item just entered, can then be emptied, to simulate a empty row. This way the BR queries will detect + generate the event + trigger the notification.

Done this obviously because I don't have steps to reproduce the empty row creation.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn