Multi-Row Variable Set Not Displaying Properly in Catalog Task

jmiskey
Kilo Sage

So I have a tricky Catalog Item/Workflow I am working on.  I need to create and pre-populate a Multi-Row Variable Set (MRVS) from a data table we have in ServiceNow.  Our ultimate goal is to have this display only on the Catalog Task that the Workflow creates once the Catalog Item is submitted, and to allow the Task assigners to fill it out, and we would like to take away the Add/Remove options from the MRVS, so all that they can do is edit the existing pre-populated records.  But we are taking this bit-by-bit.

I have run into a problem with how the MRVS is being displayed in the Task.  I have temporarily disabled my Catalog UI Policies which hide it from the Catalog Item on the Service Portal and from the RITM that gets created, to see if that helps.  So right now, it shows in all three places.

Here is what it looks like on the Service Portal:

find_real_file.png

Here is what it looks like on the RITM:

find_real_file.png

And here is what it looks like on the Task:

find_real_file.png

As you can see, for some reason, the "Actions" title is being removed from the Header row on the Task, so all the Titles are shifted over one, and do not line up with the actual data.

Does anyone have any idea on what might be causing this behavior, or do you have any idea on how to correct it?

Thanks

1 ACCEPTED SOLUTION

jmiskey
Kilo Sage

OK, so it turns out that there was an general Client Script that we had that was affecting this.

So we had to amend the Client Script which is running against the onLoad event of the Catalog Task table like this (this is just a portion of a much larger script in there that accounts for various exceptions):

		//Make variables editable if Task is active for this Catalog Item, otherwise lock
	else if(((g_form.getValue('request_item.cat_item') == "720f2816db91d010bc827afc0f9619b3"))){
		if(g_form.getValue('active') == "true"){
			g_form.setVariablesReadOnly(false);
		}else{
			g_form.setVariablesReadOnly(true);
		}
	}

Then we moved the script to hide the Add/Remove options on the MRVS out of our Catalog Client Script (that is used to pre-populate the MRVS), to a basic Client Script that runs onLoad of Catalog Task, with this code:

function onLoad() {

	//Get values
	var catItem = g_form.getValue('request_item.cat_item');
		
	//Run on Security Termination Form
	if (catItem == '720f2816db91d010bc827afc0f9619b3' && g_user.hasRole('Security Catalog')){

		setTimeout(function () {

			//hide the add/remove table
			var z = this.document.getElementsByClassName("sc-table-variable-buttons");
			//       alert(z.length);
			var k;
			for (k = 0; k < z.length; k++) {
				z[k].style.display = 'none';
			} 


			//remove "x" (delete) from individual records
			var y = this.document.getElementsByClassName("btn btn-sm icon-cross multi-row-delete-row");
			// alert(y.length);
			var j;
			for (j = 0; j < y.length; j++) {
				y[j].style.display = 'none';
			} 

		}, 1000);

	}

}

Once we did all this, the headers appeared as they should.  (Note: We chose to do the above script in a Client Script, so we can re-use it easily if we have other MRVS that we want to set up in the same manner).

So we have the MRVS only being displayed on the Catalog Task (not on Catalog Item or Requested Item).  We use a Catalog UI Policy to hide it in theose places.  The Catalog Client Script that pre-populates the MVRS only runs against the Catalog Item.  That prevents it from re-running and overwriting all changes made to it when it is opened up in the Task. 

The variables are editable only while the Task is active.  Once it is closed, everything is locked down, which is exactly the way we need it to work.

So, finally, eveything working just the way we needed!

Thanks to all who chimed in and helped steer me in the proper direction.

 

 

View solution in original post

12 REPLIES 12

Hi,

So hiding those 2 buttons is a requirement

What is the issue then?

Regards
Ankur

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

I explained it all in my first post.  The issue is with the Header row of the MRVS showing up on the Catalog Task.  The "Actions" header is missing, and all the other headings shifted over, so the headers are not above the correct fields.

I show exactly what is happening in the original post, with images.  Note the third image.

PratyushaBodepu
Mega Guru
Is there anything that is making the MRVS read-only in the task?

No, I am able to edit the MRVS records from the Task.

 

Hi,

Please find below response

1) Ensure "Isolate Script" field on client script is set to false

this worked for me in hiding the ADD and Remove All buttons on SC Task

If you want to hide it only for Catalog task then you need to uncheck the "Applies on Catalog Item" and "Applies on Requested Item" checkbox from client script

The ADD button has class as -> btn btn-primary

The Remove All button has class as -> btn btn-default

var z = this.document.getElementsByClassName("btn btn-primary");
		var k;
		for (k = 0; k < z.length; k++) {
			if (z[k].getAttribute("title") ==  'You can add only 50 rows'){
				z[k].style.display = 'none';
			}
		} 

var z = this.document.getElementsByClassName("btn btn-default");
		var k;
		for (k = 0; k < z.length; k++) {
			if (z[k].innerHTML ==  'Remove All'){
				z[k].style.display = 'none';
			}
		} 

find_real_file.png

Output:

find_real_file.png

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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