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

Sam Dey1
Kilo Guru

Hi Max,

I have had similar issues for a client. So basically in my case, the MRVS was autopopulated with some data and the user was suppose to enter rest of the data in the following columns. But if they wont then the some columns would remain empty. 

Anyhow, to tackle this I had to use a onSubmit client script (onChange wont work as desirably). Following is the onSubmit script -

 

var isNotEmpty = true;
 
/*
Make an array of MRVS internal name and the MRVS fields which you want to validate for empty rows.
 
In the following case MRVS internal name is mrvs_2 and the field name is field_4 and so on.
 
*/
var mrvsArr = [
{
  mrvsName:"mrvs_2",
  fieldName:"field_4"
},
{
  mrvsName:"mrvs_2",
  fieldName:"field_5"
},
{
  mrvsName:"mrvs_2",
  fieldName:"field_6"
}
];
 
/*
Next we iterate through each element of the above constructed array;
Check if the MRVS is empty or not if not then getValue of the entire mrvs. This is done so that if the whole MRVS is not mandatory then user dont have to be bothered about filling up column. 
 
Once we get the MRVS data, we parse it and check the length, if the length is greater than 0, which means some of the fields have got data or the MRVS has got a row atleast. 
We iterate the content of the MRVS getValue variable for each row we check if column in the row is empty or not, if empty then alert a message and break the for loop and assign a flag variable as false;
Finally the script returns false if the the flag is set to false and the user now cant submit with empty rows.
*/

mrvsArr.forEach(function (el) {
  vartempMRVS_Data=g_form.getValue(el["mrvsName"]) !=""?JSON.parse(g_form.getValue(el["mrvsName"])) : [];
  if (tempMRVS_Data.length>0) {
     for (vari=0; i<tempMRVS_Data.length; i++) {
         if (tempMRVS_Data[i][el.fieldName]) {
            isNotEmpty=false;
            alert("Row Cannot be empty");
            break;
          }
      }
  }
});

return isNotEmpty;
 
This is working in my personal instance, let me know if there is any issue. 
 
Cheers,
Sam

Max_
Mega Contributor

Thank you.
Looks very interesting. Not sure if we can use this, because so far we don't know how this is occuring and cannot reproduce this. Maybe this could benefit us eventually, so I will bookmark this one. But for now, focussing on getting triggered when this behavior occurs so we can try to analyze and reproduce it.

Max

Hi Max,

 

Sorry I misinterpreted your question. 

So just one more thing, does the cat item/ record producer table and where you are viewing the submitted form data, is that same table?

With the OOTB macro that renders the submitted form data, this shouldn't be an issue but with cases where you create record in one table and the end user have access to a different table's record (which is copied from the actual table) this issue shows up.

 

Cheers,

Sam

Max_
Mega Contributor

Yeah we checked, the values for all records belonging to the row in the multi row question answer table, are actually all empty. We don't know if somehow a user could submit an empty row (which we haven't been able to reproduce yet) or that there is a bug/error/or someting. That's also why we are looking into monitoring this. 

Max

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