Comments on: Advanced Reference Qualifier Using a Script Include https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 15:41:43 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mila Morales https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8588 Thu, 07 Sep 2017 19:02:11 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8588 In reply to Andrea Zaffaroni.

You must create a dictionary entry override for the incident table. In order to do that you need to do the following:
Configure the dictionary of assignment_group
Go to the Dictionary Overrides related list
Click new and specify the table you want to override, in your case the Incident.
Check the Override reference qualifier and populate the Reference qualifier field with your script include.
Save the record.

]]>
By: Andrea Zaffaroni https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8587 Fri, 26 May 2017 17:33:39 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8587 Hi I have a problem: I call a Script Include in the assignmnent_group field of the incidents… but unfortunately I found the same call also in the assignmnent_group of Changes and Problems. How can I fix this problem?

]]>
By: Mark Stanger https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8586 Wed, 28 Oct 2015 11:27:27 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8586 In reply to salva.

I don’t believe so.

]]>
By: salva https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8585 Wed, 28 Oct 2015 10:30:52 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8585 In reply to Mark Stanger.

Is it possible to put an condition in the attribute field? if the assign_to field is not empty then tree_picker=false.

]]>
By: April https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8584 Mon, 29 Jun 2015 21:03:03 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8584 In reply to Mark Stanger.

Thank you!

]]>
By: Mark Stanger https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8583 Mon, 29 Jun 2015 18:03:58 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8583 In reply to April.

Hey April. These types of questions are probably better suited to the ServiceNow community site. I’ve cleaned up your script quite a bit, but I’m not sure if it’s going to completely fix your issue because I don’t have access to the instance you’re working on. This script should eliminate the errors you’re seeing (and solve several other issues I noticed). If you have further questions please ask on the ServiceNow community site.

function u_INC_FilterAssignmentOnDisableTrigger(){
	/**Create function to use a reference qualifier on the assignment group field on the Incident form to evaluate the value of the checkbox field on the CI and if the box is checked, the Assignment Group will NOT auto-populate on the incident form but rather provide the parent and child assignment groups to select from. If the u_disable_auto_populate_assign box is not checked, auto populate the Incident Assignment group field with the support group assigned to the choice CI**/
	
	var current_source = current.cmdb_ci;
	var answer = current.assignment.group;
	
	if(current.cmdb_ci.u_disable_auto_populate_assign == true){
		//return parent and child assignment groups in the lookup for the CI selected (but don't default populate anything)
		answer = 'parentIN' + current.assignment_group + ',' + current.cmdb_ci.support_group;
	}
	
	if(current.cmdb_ci.u_disable_auto_populate_assign != true){
		//Auto Populate the group assigned to cmdb_ci
		answer = current.cmdb_ci.support_group;
	}
	
	return answer;
}
]]>
By: April https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8582 Mon, 29 Jun 2015 16:34:10 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8582 Hey Mark, thanks for the article I’m trying to do this exact thing – create a Script Includes to use as a reference qualifier and I’m having issues, can you help?

Here is what I have so far:

function u_INC_FilterAssignmentOnDisableTrigger()

//Create function to use a reference qualifier on the assignment group field on the Incident form to evaluate the value of the checkbox field on the CI and if the box is checked, the Assignment Group will NOT auto-populate on the incident form but rather provide the parent and child assignment groups to select from. If the u_disable_auto_populate_assign box is not checked, auto populate the Incident Assignment group field with the support group assigned to the choice CI
{
var current_source = current.cmdb_ci;
var answer = current.assignment.group;
 
if(current.cmdb_ci.u_disable_auto_populate_assign == true) //return parent & child assignment groups in the lookup for the CI selected (but don't default populate anything)
  answer= 'parentIN' + current.assignment_group + ',' + current.cmdb_ci.support_group;
 
if(current.cmdb_ci.u_disable_auto_populate_assign =!true) //Auto Populate the group assigned to cmdb_ci
answer= 'assignment.cmdb_ci';
 
return answer;
}
return'';
}

But I’m still getting the following errors:
WARNING at line 9: Missing semicolon.

ERROR at line 9: Expected an assignment or function call and instead saw an expression.

I’m assuming that after I get this script correct I’d just need to create a dynamic or advance reference qualifier on my assignment group field (ie javascript: u_INC_FilterAssignmentOnDisableTrigger)…… am I right?

]]>
By: Mark Stanger https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8581 Tue, 14 Oct 2014 19:25:19 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8581 In reply to Jef De Coster.

Thanks for the contribution! Please keep us up-to-date on any modifications or improvements you make.

]]>
By: Jef De Coster https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8580 Tue, 14 Oct 2014 19:11:50 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8580 Hi All,

made this a little bit more versatile.
you can use it on Service Catalog variables as well.
You can call it from any reference field’s advanced qualifier, as you can specify the reference field targettable

Tested it out and works…

Now reviewing setting the default value of the reference field to the first retrieved record, on change of the filtervaluefield

Any feedback is welcome ;-) (as I’m quite rusty in my scripting, and a newbie in Snow)

/*
*-----------------------------------------------------------------------------------------------------------------
* BEGIN SCRIPT INCLUDE Script
*-----------------------------------------------------------------------------------------------------------------
*/
	/*
	* Script assembled by using examples and solution provided by:
	* SNGuru - Advanced Reference Qualifier Using a Script Include
	* https://servicenowguru.com/scripting/script-includes-scripting/advanced-reference-qualifier-script-include/
	* 
	* Script tested in Maxthon Cloud Browser v. 4.4.1.5000
	*
	* Script author : Jef De Coster for Devoteam Belgium 
	* 
	*/
	/*
	*Script specifics:
	*getAdvancedQualifier will get and set the advanced qualification on any reference Field
	*
	*Set Advanced Qualification Filter on any Reference Field.
	*Using 3 variables: "targetTable","filterField","filterValueField to pass thorugh,
	*Will build Qualifier to use in advanced qualifier of a reference field to filter
	*against filterField CONTAINS filterValueField
	*
	* Can be called as for example:
	* javascript:new dvt_ReferenceFieldFunctions().getAdvancedQualifier(targetTable,filterField,filterValueField)
	*	Get the advanced qualifier for referenced table cmdb_ci_hardware, using assigned_to filterfield against caller_id value on current form:
	*		javascript:new dvt_ReferenceFieldFunctions().getAdvancedQualifier("cmdb_ci_hardware","assigned_to","caller_id");
	*	In this example the advanced qualifier of a variable on Record Producer will be set only showing the hardware for the caller.
	*/
var dvt_ReferenceFieldFunctions = Class.create();
dvt_ReferenceFieldFunctions.prototype = {
	initialize: function() {
	},
	// First real function that will get the Advanced Qualifier
	getAdvancedQualifier : function(targetTable,filterField,filterValueField) {
	
	//Variables
		// answer will contain return value
		var answer = '';
		// includes is used to get the Value from the variables pool from  variable 
		var includes = current[filterValueField];
				//gs.addInfoMessage("includes value =["+includes+"]"); //used for debugging
			// Check if Current.filterValueField isn't "undefined" 
			// This is the case if we are using this function from a Service Catalog Item 
			// (eg. Record Producer,...)
			if (!includes) {
				// In case the value is undefined we'll search for a variable 
				// This way this is usable on Service Catalog Item
				includes = current.variables[filterValueField];
			}
		// GlRec will be used as the gliderecord on the  table
		var GlRec = new GlideRecord(targetTable); 
	// Set Query to initiate against the target Table
		// Uses filterField to set against which field to query
		// Uses includes to use as Value to query against
		GlRec.addQuery(filterField,'CONTAINS',includes); 
	// Execute Query
		GlRec.query(); 
	// Loop through recordset an get the sys_id(s)
		while (GlRec.next()) { 
			if (answer.length > 0) {
			answer += (',' + GlRec.sys_id);
			} 
			else { 
			answer = '' + GlRec.sys_id;
			} 
		} 
	// return the result
		return 'sys_idIN' + answer; 
	},
	
    type: 'dvt_ReferenceFieldFunctions'
};
/*
*-----------------------------------------------------------------------------------------------------------------
* END SCRIPT INCLUDE Script
*-----------------------------------------------------------------------------------------------------------------
*/
]]>
By: Aritha https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/#comment-8579 Mon, 15 Jul 2013 15:09:34 +0000 https://servicenowguru.wpengine.com/?p=3751#comment-8579 Can this be used on a Service Catalog variable?

]]>