Incident Related List - Change Request-->Parent, and bulk adding CR to Incident

robinsamberg
Tera Expert

Hello all,

Recently I added the change request--->parent related list to our incident form.  The group who want to use that list need to be able to bulk-add CRs in the related list. 

Problem:  They click the ADD button in the related list, but in the modal window, they are unable to change the filter to show ALL change requests, including those that are closed (for historical purposes, I suppose). 

I see a condition on the "ADD" UI Action button, but I'm afraid I can't figure out what to modify.  Is it possible for the filter here to be editable?  If so where would I find the seemingly hard-coded filter?

find_real_file.png

 

find_real_file.png

Thanks very much for any assistance

Robin

 

1 ACCEPTED SOLUTION

7bitew
Tera Expert

Hi Robin,

The Add UI Action calls the function getURL from the BulkAddChangeRequest script include. This function is responsible for returning the url for the appropriate list view so the Bulk Add feature works appropriately.

The problem you are running into is the url is returning what's called a fixed query. This is a query that the user cannot remove. In order to correct this, you would have to remove the fixed query from the BulkAddChangeRequest script. 

find_real_file.png

I've highlighted the code responsible for this in that script include above.You can modify the code slightly to move the "active=true" condition into the editable query as described below:

	getURL: function(){
		var sysId = this.getParameter(this.PARAMS.SYSID);
		var url = new GlideURL("task_add_change_req.do");
		var fixedQuery = "parentISEMPTY";
		url.set(this.PARAMS.SYSID, sysId);
		url.set(this.PARAMS.VIEW, "default");
		url.set(this.PARAMS.NOSTACK, "true");
		url.set(this.PARAMS.QUERY, "active=true^ORDERBYDESCsys_created_on");
		url.set(this.PARAMS.TABLE, "change_request");
		url.set(this.PARAMS.FIXEDQUERY, fixedQuery);
		return url;
	},

This will make the filter work as you intend:

find_real_file.png

Take special note though, this is modifying an out of the box Script Include, which could impact you during an upgrade if ServiceNow changes this code. This will be flagged as a conflict / customer edit and the Script Include code will need to be merged manually during the upgrade process.

Thanks,

Ed

View solution in original post

4 REPLIES 4

sachin_namjoshi
Kilo Patron
Kilo Patron

Use List Control to update related list default filter.

 

  1. Right-click a related list column header and click Configure > List Control
  2. Configure the form to add the Edit default filter field, if necessary.
  3. Using the condition builder, create a default filter.
  4. Click Update.
    When users click the Edit button in the related list, the list of records they can select is filtered according to the default filter.

 

Regards,

Sachin

robinsamberg
Tera Expert

Hi Sachin, thanks for your suggestion - however my user is wanting to use the ADD button in the related list, not the edit button.  

Edit brings them the slushbucket, not what we are after in this case.

Add brings up a modal list of change requests, but the list presented is filtered to active changes only.  We need to make this modal present ALL, regardless of state.  Can't find the right place to change that.  

find_real_file.png

 

7bitew
Tera Expert

Hi Robin,

The Add UI Action calls the function getURL from the BulkAddChangeRequest script include. This function is responsible for returning the url for the appropriate list view so the Bulk Add feature works appropriately.

The problem you are running into is the url is returning what's called a fixed query. This is a query that the user cannot remove. In order to correct this, you would have to remove the fixed query from the BulkAddChangeRequest script. 

find_real_file.png

I've highlighted the code responsible for this in that script include above.You can modify the code slightly to move the "active=true" condition into the editable query as described below:

	getURL: function(){
		var sysId = this.getParameter(this.PARAMS.SYSID);
		var url = new GlideURL("task_add_change_req.do");
		var fixedQuery = "parentISEMPTY";
		url.set(this.PARAMS.SYSID, sysId);
		url.set(this.PARAMS.VIEW, "default");
		url.set(this.PARAMS.NOSTACK, "true");
		url.set(this.PARAMS.QUERY, "active=true^ORDERBYDESCsys_created_on");
		url.set(this.PARAMS.TABLE, "change_request");
		url.set(this.PARAMS.FIXEDQUERY, fixedQuery);
		return url;
	},

This will make the filter work as you intend:

find_real_file.png

Take special note though, this is modifying an out of the box Script Include, which could impact you during an upgrade if ServiceNow changes this code. This will be flagged as a conflict / customer edit and the Script Include code will need to be merged manually during the upgrade process.

Thanks,

Ed

Ed - thank you sir, that is what I was looking for.  I knew it was scripted, just couldn't track it down.  Made the change and notated it with comments, so we should be ok if an upgrade flags it.  Appreciate the heads up on that as well.  

 

Thanks so much!
Robin