Murray Johnston
Kilo Explorer

Desire: Standard changes (existing or newly created) should have a dedicated view, which will limit the fields and related lists with which the user must concern themselves.

Issue: While view rules allow an easy filter condition (type=standard) to apply a view to 'existing' standard changes, this filter will not apply to 'new' records while the user is completing for initial submission.  Out of the box, the standard changes created from the Standard Change Catalog plugin (com.snc.change_management.standard_change_catalog) do not have any view which applies to them, or any obvious way to associate a view with them.

Solution: Create a scripted view rule which will parse specific data points from the URI, based on the URI submitted by the catalog record producers in the standard change catalog.

 

(function overrideView(view, is_list) {
    if (paramContainsValue("sysparm_query","type%3dstandard%5e") && paramContainsValue("sysparm_catalog_view", "catalog_default") && paramContainsValue("sys_id", "-1")) {
		answer = "standard_change";  // set the name of the view to use as answer
	}
	
	function paramContainsValue(paramName, strValue) {
		if (!paramName || !strValue) {
			return false;
		}
		
		var strURI = gs.action.getGlideURI().toString();
		var iPosQ = strURI.indexOf("?");
		var query_params = [];
		
		if (iPosQ != -1) {
			var strParams = strURI.substring(iPosQ + 1);
			query_params = strParams.split("&");
		}
			
			//gs.log("View rule for change_request:\n" + strURI + "\nparameters: " + JSON.stringify(query_params), "nav_handler_change_request");
		
		if (query_params.length == 0) {
			return false;
		}
		
		for (var p = 0; p < query_params.length; p++) {
			var thisParamKeyVal = query_params[p].split("=");
			
			if (thisParamKeyVal[0].toLowerCase() == paramName.toString().toLowerCase()) {
				// Parameter name matches.  Check if the value contains
				if (thisParamKeyVal[1].indexOf(strValue) != -1) {
					// Found this value
					return true;
				}
			}
		}
		
		// if we're here, no match was found
		return false;
	}
})(view, is_list);
Version history
Last update:
‎11-06-2018 05:30 AM
Updated by: