Disable process conditionally

Is it possible to remove or somehow disable processes that are in "Run process" context menu according to some conditions? For example, I'd like to disable a process on section page and allow it on edit page but only if the object has a particular status. If it's not possible - how else can I achieve similar functionality?

Like 0

Like

4 comments

You need to create replacing modules for the case page and for the case section. Then write the code that will match your needs there. Please find the example below.

define("CaseSection", ["BaseFiltersGenerateModule", "CheckBoxFixedFilterStyle", "StorageUtilities",
			"ServiceDeskConstants", "CasePageUtilitiesV2", "css!CheckBoxFixedFilterStyle"],
		function(BaseFiltersGenerateModule, CheckBoxFixedFilterStyle, StorageUtilities, ServiceDeskConstants) {
			return {
				entitySchemaName: "Case",
				contextHelpId: "1001",
				mixins: {},
				attributes: {
					"UsrIsProcessButtonVisible": {
						dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
						type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
						value: false
					}
				},
				messages: {},
				methods: {
					init: function() {
						this.callParent(arguments);
						this.set("UsrIsProcessButtonVisible");
					}
				},
				diff: /**SCHEMA_DIFF*/[
					{
						"operation": "merge",
						"name": "ProcessButton",
						"values": {
							"visible": {"bindTo": "UsrIsProcessButtonVisible"}
						}
					},
					{
						"operation": "merge",
						"name": "DataGridRunProcessAction",
						"values": {
							"visible": {"bindTo": "UsrIsProcessButtonVisible"}
						}
					}
				]/**SCHEMA_DIFF*/
			};
		});

 

define("CasePage", [], function() {
	return {
		entitySchemaName: "Case",
		attributes: {
			"UsrIsProcessButtonVisible": {
				dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
				type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				value: false
			}
		},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.set("UsrIsProcessButtonVisible");
			}
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "ProcessButton",
				"values": {
					"visible": {"bindTo": "UsrIsProcessButtonVisible"}
				}
			}
		]/**SCHEMA_DIFF*/
	};
});

 

Thank you. And do you know if it's possible to disable or hide single context menu item? For example if I have two processes I may want to disable one but not the other.

You need to override methods from the ProcessEntryPointUtilities mixin in the CaseSection and CasePage modules. For example, for the button on a grid record you'll need to override the addRecordRunProcessMenuItems method in the CaseSection module. 

http://prntscr.com/jzm8w0

Thank you very much.

Show all comments