Special Mandatory Requirements for Multi-Row Variable Set (MRVS)

jmiskey
Kilo Sage

We have a Termination Request Catalog Item on our Service Portal.  Basically, the manager selects the user and the term date, and submits the request.  Then, a Task is created for our Security team to verify and delete all the user's accounts.

The list of Security Applications is constantly changeing, and we do not want to have to edit the Catalog Item every time one changes.  To get around that, what we did is create a custom table that lists all the Security Applications, and an Active flag to show if those Applications are currently active or not.  Then, on the Catalog Item, we have a Multi-Row Variable Set (MRVS) that is pre-populated with the list of Active Security Applications.  This MRVS is hidden from the Catalog Item and the RITM, and only is displayed on the Task for Security.  We have removed the Add/Remove capabiities from the MRVS, so all they can do on the Task is edit the records lthat have been pre-populated.

Our MRVS shows three fields:

- Application Name: this is pre-populated and made read-only, so they cannot change it on the Task

- Has Account?: this is a multiple choice field, with options "Yes" and "No"

- User ID: this is a text field that becomes required if they mark "Yes" for "Has Account"?

So an excerpt from this MRVS looks like this:

find_real_file.png

In actuality, there are about 30 Applications listed.  Everything is working great, but there is one more thing we want/need to do.  For every Application listed, we want to require them to put a "Yes" or "No" in the "Has Account?" field (this indicates to our auditors that they have checked every single Application).  We made the field a required field, but that only takes affect if they actually choose to edit that record.  If they do not edit every record listed, then they can Close the task without filling out that field for every record.

So the question is, how can we ensure that they have edited every record, and every records has a "Yes" or "No" in the "Has Account?" field before Closing the task?

Thanks.

 

 

14 REPLIES 14

OK, we think we know why it is not working.  I don't think it is grabbing the MRVS, and we cannot use "g_form.getValue" on it, as the updates the user is making on the Task haven't been saved yet.  But we are not sure then how to get the information we need for this.

To summarize, here are the important details:

- The MRVS is being created at the Catalog Item level, but is being hidden from the Catalog Item and the RITM.

- This verification should be running on the submission of the Catalog Task (the user will be going in to the Task, entering the new values into the MRVS, and closing the task).

Does anyone have any idea how we can do that?

@jmiskey 

few corrections

1) your MRVS variable name is "security_applications" but you are just using application variable inside your g_form.getValue()

2) Since you want this only for catalog task ensure Applies on Catalog Task checkbox is true

3) Also have it as onSubmit catalog client script "Applies to" catalog item

Updated script below:

function onSubmit(){

var value = g_form.getValue('security_applications');

var parser = JSON.parse();

var isPresent = true;

for(var i=0;i<parser.length;i++){

if(parser[i].has_account == ''){
isPresent = false;
break;
}

}

if(isPresent.toString() == 'false'){
alert('Please give has account for pending row');
return false;
}

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur,

Thanks for the reply.  Sorry for the delay in responding.  I was on vacation/holiday last week.

I see that there may be a little confusion, so let me clear up a few things:

"security_applications" is the name of the Multi-Row Variable Set

"application" is the name of the first field in my Multi-Row Variable Set.

It is set to Mandatory, and is the field that is automatically being populated.

 

I thought that g_form.getValue(...) would have to be applied to field on the Form, and not to the whole MRVS (which has two other fields, in addition to "application").  Is that correct?

Also, can you clarify if the code should be placed on the Catalog Client Script right in the MRVS, or should be a Catalog Client Script at the Catalog level (of the Catalog containing the MRVS)?  I have tried both, and neither seem to work.

Lastly, I am a little confsued about what you are saying here:

"3) Also have it as onSubmit catalog client script "Applies to" catalog item"

Do you mean that we should check the "Applies on Catalog Item View" box (even though it is not being shown on the Catalog Item on the Service Portal) or do you mean something else?

Here is what the top half of my Catalog Client Script looks like:

find_real_file.png

Hi,

since you require it to run on Catalog Task Set "Applies on Catalog Task" as true

you need to stop the form saving if they don't give the application that is the reason onSubmit client script is required using which you can validate

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur,

As can can be seen from the screen print in my last post, I already have those settings set that way.  But it still is not working.  It does not seem to do anything, and allows them to Close the Task without updating all the records in the MRVS.

I tried the code with:

var value = g_form.getValue('security_applications');

and with

var value = g_form.getValue('application');

and neither one seems to work.

 

Do you have any thoughts/comments on what I posted back 13 days ago:

OK, we think we know why it is not working.  I don't think it is grabbing the MRVS, and we cannot use "g_form.getValue" on it, as the updates the user is making on the Task haven't been saved yet.  But we are not sure then how to get the information we need for this.

To summarize, here are the important details:

- The MRVS is being created at the Catalog Item level, but is being hidden from the Catalog Item and the RITM.

- This verification should be running on the submission of the Catalog Task (the user will be going in to the Task, entering the new values into the MRVS, and closing the task).