Case description:
You need to add a button to the Opportunity edit page.
Algorithm of realization:
- Create replacing client schema for your page.
- Create localizable string which will contain caption of the button.
Figure 1. Adding a localizable string
-
Source code of the "OpportunityPageV2" :
define("OpportunityPageV2", [], function() { return { entitySchemaName: "Opportunity", messages: { "SetNewQuoteButtonVisibility": { mode: this.Terrasoft.MessageMode.PTP, direction: this.Terrasoft.MessageDirectionType.PUBLISH } }, methods: { onNewQuoteClick: function() { //TODO: implement your logic here this.showInformationDialog("Hello"); }, getNewQuoteButtonVisible: function() { var newMode = this.isNewMode(); var result = !newMode; //TODO: implement your logic for visibility here this.sandbox.publish("SetNewQuoteButtonVisibility", result, [this.sandbox.id]); return result; } }, diff: /**SCHEMA_DIFF*/[ { "operation": "insert", "name": "NewQuoteButton", "parentName": "LeftContainer", "propertyName": "items", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, "style": Terrasoft.controls.ButtonEnums.style.DEFAULT, "caption": {"bindTo": "Resources.Strings.NewQuoteBtn"}, "click": {"bindTo": "onNewQuoteClick"}, "visible": {"bindTo": "getNewQuoteButtonVisible"}, "classes": { "textClass": ["actions-button-margin-right"] } } } ]/**SCHEMA_DIFF*/ }; });
- Create replacing client schema for the section.
-
Create section's localizable string for a button caption.
define("OpportunitySectionV2", [], function() { return { attributes: { "IsNewQuoteButtonVisible": { dataValueType: this.Terrasoft.DataValueType.BOOLEAN, value: false } }, messages: { "SetNewQuoteButtonVisibility": { mode: this.Terrasoft.MessageMode.PTP, direction: this.Terrasoft.MessageDirectionType.SUBSCRIBE } }, methods: { subscribeSandboxEvents: function() { this.callParent(arguments); this.sandbox.subscribe("SetNewQuoteButtonVisibility", function(result) { this.set("IsNewQuoteButtonVisible", result); }, this, [this.getCardModuleSandboxId()]); } }, diff: /**SCHEMA_DIFF*/[ { "operation": "insert", "name": "NewQuoteButton", "parentName": "CombinedModeActionButtonsCardLeftContainer", "propertyName": "items", "values": { "itemType": Terrasoft.ViewItemType.BUTTON, "style": Terrasoft.controls.ButtonEnums.style.DEFAULT, "caption": {"bindTo": "Resources.Strings.NewQuoteBtn"}, "visible": { "bindTo": "IsNewQuoteButtonVisible" }, "click": {"bindTo": "onCardAction"}, "tag": "onNewQuoteClick", "classes": { "textClass": ["actions-button-margin-right"] } } } ]/**SCHEMA_DIFF*/ }; });
The result would be: