Update detail when field on parent object changes value

Hi,

In creatio, I have created a section which has a detail. The section's object has a field named 'Stage'. When 'Stage' value changes I want to refresh grid detail action buttons without page reloading, so that I can remove the + button (for adding) and the actions for copying, editing, deleting and Data Import.

I have tried using 'updateDetail' and 'reloadEntiy' but they don't seem to refresh these buttons

Like 0

Like

2 comments
Best reply

Hello,

 

Not sure about removing buttons (but theoretically it's possible using the "Visible" property), but as for the "Enabled" property, it's possible to control the state of the button. This can be achieved using sandbox messages exchange mechanisms like (control the copy button "Enabled" property in the detail on the case page based on the case category selected):

 

CasePage schema

messages: {
			"UpdateActionsStatuses": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			}
		},
		...
onCategoryChanged: function() {
				this.callParent(arguments);
				this.sandbox.publish("UpdateActionsStatuses", this.get("Category"), ["ForActionsStatusUpdate"]);
			}

 

Detail schema

messages: {
			"UpdateActionsStatuses": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			}
		},
....
CopyRecordMenuItemEnabled: {
                    dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
                    value: false
			},
....
getCopyRecordMenuItem: function() {
				return this.getButtonMenuItem({
					Caption: {"bindTo": "Resources.Strings.CopyMenuCaption"},
					Click: {"bindTo": "copyRecord"},
					Enabled: {bindTo: "CopyRecordMenuItemEnabled"},
					Visible: {bindTo: "IsEnabled"}
				});
			},
....
subscribeSandboxEvents: function() {
				this.callParent(arguments);
				this.sandbox.subscribe("UpdateActionsStatuses", this.updateActionsStatus, this,
						["ForActionsStatusUpdate"]);
			},
 
			updateActionsStatus: function(result) {
				var parentCaseCategory = result.displayValue;
				var isCategoryCorrect = parentCaseCategory == "PPE Case (Sales Contract)";
				this.updateCopyRecordMenuItem(isCategoryCorrect);
			},
 
			updateCopyRecordMenuItem: function(isCategoryCorrect) {
				var parentCopyRecordEnabled = this.getCopyRecordMenuEnabled();
				var isEnableCopyRecordMenuItem = isCategoryCorrect && parentCopyRecordEnabled;
				this.set("CopyRecordMenuItemEnabled", isEnableCopyRecordMenuItem);
			}

 

As a result the copy button will be enabled in the detail only if any record is selected in the detail and also if the case category (case page is where the detail is added) is "PPE Case (Sales Contract)".

Hello,

 

Not sure about removing buttons (but theoretically it's possible using the "Visible" property), but as for the "Enabled" property, it's possible to control the state of the button. This can be achieved using sandbox messages exchange mechanisms like (control the copy button "Enabled" property in the detail on the case page based on the case category selected):

 

CasePage schema

messages: {
			"UpdateActionsStatuses": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			}
		},
		...
onCategoryChanged: function() {
				this.callParent(arguments);
				this.sandbox.publish("UpdateActionsStatuses", this.get("Category"), ["ForActionsStatusUpdate"]);
			}

 

Detail schema

messages: {
			"UpdateActionsStatuses": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			}
		},
....
CopyRecordMenuItemEnabled: {
                    dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
                    value: false
			},
....
getCopyRecordMenuItem: function() {
				return this.getButtonMenuItem({
					Caption: {"bindTo": "Resources.Strings.CopyMenuCaption"},
					Click: {"bindTo": "copyRecord"},
					Enabled: {bindTo: "CopyRecordMenuItemEnabled"},
					Visible: {bindTo: "IsEnabled"}
				});
			},
....
subscribeSandboxEvents: function() {
				this.callParent(arguments);
				this.sandbox.subscribe("UpdateActionsStatuses", this.updateActionsStatus, this,
						["ForActionsStatusUpdate"]);
			},
 
			updateActionsStatus: function(result) {
				var parentCaseCategory = result.displayValue;
				var isCategoryCorrect = parentCaseCategory == "PPE Case (Sales Contract)";
				this.updateCopyRecordMenuItem(isCategoryCorrect);
			},
 
			updateCopyRecordMenuItem: function(isCategoryCorrect) {
				var parentCopyRecordEnabled = this.getCopyRecordMenuEnabled();
				var isEnableCopyRecordMenuItem = isCategoryCorrect && parentCopyRecordEnabled;
				this.set("CopyRecordMenuItemEnabled", isEnableCopyRecordMenuItem);
			}

 

As a result the copy button will be enabled in the detail only if any record is selected in the detail and also if the case category (case page is where the detail is added) is "PPE Case (Sales Contract)".

Yes, it worked. Thank you

Show all comments