Add custom button to the section analytics view page

We need to add a custom button to the section analytical view page, which will trigger a business process.

 

 

Is it possible ?

Like 0

Like

3 comments

 This container you are referring to is supposed to store DataViews in it (please take a look at the getDefaultDataViews method from the BaseDataView module). It is not supposed to store buttons in it.

 

It is better to add the button to a separate container created in the FiltersContainer container and bind process execution to this button. As an example I've added the button to the contact section analytics data view:

define("ContactSectionV2", ["ProcessModuleUtilities"],
	function(ProcessModuleUtilities) {
		return {
			entitySchemaName: "Contact",
			attributes: {},
			messages: {},
			methods: {
				runCustomProcess: function() {
					var config = {
						sysProcessName: "UsrProcess_eedcaa6"
					};
					ProcessModuleUtilities.executeProcess(config);
				}
			},
			diff: /**SCHEMA_DIFF*/ [
				{
					"operation": "insert",
					"name": "CustomButtonContainer",
					"parentName": "FiltersContainer",
					"propertyName": "items",
					"values": {
						"itemType": Terrasoft.ViewItemType.CONTAINER,
						"items": []
 
				},
				{
					"operation":"insert",
					"name": "TestProcessButton",
					"parentName": "CustomButtonContainer",
					"propertyName": "items",
					"values": {
						"itemType": Terrasoft.ViewItemType.BUTTON,
						"caption": {bindTo: "Resources.Strings.CustomButtonCaption"},
						"click": {bindTo: "runCustomProcess"},
						"style": Terrasoft.controls.ButtonEnums.style.GREEN
					}
				}
				] /**SCHEMA_DIFF*/
		};
	});

And connected custom process execution when clicking the button. As a result the button appeared on the page as expected:

And a custom process was executed upon clicking it.

 

Best regards,

Oscar

Oleg Drobina,

Hi Oleg

 

Couple of questions. If I just wanted this button to appear on List View of the Section Page rather than the Analytics what would need to change?

 

Also does this code create the custom button here or does that need to be created elsewhere and it is just referenced here?

 

thanks

Rob Watson,

 

Hello Rob,

 

For the first question: I used the FiltersContainer container as a parent for the button, but it has the logic that it's hidden in the list view and is displayed only in analytics view (logic of the saveFiltersContainersVisibility method). In this case logic like this should be used:

methods: {
...
loadAnalyticsDataView: function() {
					this.set("IsCustomButtonContainerVisible", false);
					this.callParent(arguments);
				},
 
				loadGridDataView: function() {
					this.set("IsCustomButtonContainerVisible", true);
					this.callParent(arguments);
				},
...
 
diff: [
...
{
					"operation": "insert",
					"name": "CustomButtonContainer",
					"parentName": "QuickFilterModuleContainer",
					"propertyName": "items",
					"values": {
						"itemType": Terrasoft.ViewItemType.CONTAINER,
						"visible": { "bindTo": "IsCustomButtonContainerVisible" },
						"items": []
					}
				},
				{
					"operation":"insert",
					"name": "TestProcessButton",
					"parentName": "CustomButtonContainer",
					"propertyName": "items",
					"values": {
						"itemType": Terrasoft.ViewItemType.BUTTON,
						"caption": {bindTo: "Resources.Strings.CustomButtonCaption"},
						"click": {bindTo: "runCustomProcess"},
						"style": Terrasoft.controls.ButtonEnums.style.GREEN
					}
				}
...
]

We change a parent item for the "CustomButtonContainer" to "QuickFilterModuleContainer". As a result button will be visible only in list view and will be hidden in analytics view.

 

As for the second quesion: the button is created in the schema diff directly (container + button itself).

Show all comments