Hello!
I would like to provide an example of how to add a merge records button for details in the Classic UI interface.
Example based on the address details in the contact page - schema ContactAddressDetailV2:
1. Create an overriding module for the ContactAddressDetailV2 schema through the configuration section.
2. Add the schema code:
define("ContactAddressDetailV2", ["RightUtilities","SectionMergeHelper","DuplicatesSearchUtilitiesV2","DuplicatesMergeHelper"],
function(RightUtilities){
return {
mixins: {
DuplicatesSearchUtilities: "Terrasoft.DuplicatesSearchUtilitiesV2",
DuplicatesMergeHelper: "Terrasoft.DuplicatesMergeHelper",
SectionMergeHelper: "Terrasoft.SectionMergeHelper"
},
messages: {
/**
* @message Merge
* Merge records.
* @param {Object} Merge config.
*/
"Merge": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.SUBSCRIBE
}
},
attributes : {
IsMergeRecordsButtonVisible: {
dataValueType: Terrasoft.DataValueType.BOOLEAN,
value: true
},
},
methods : {
addGridOperationsMenuItems : function(toolsButtonMenu){
this.callParent(arguments);
toolsButtonMenu.addItem(this.getButtonMenuSeparator());
toolsButtonMenu.addItem(this.MergeRecords());
},
MergeRecords: function() {
return this.getButtonMenuItem({
Caption: {"bindTo": "Resources.Strings.MergeRecordsButtonCaption"},
Click: {"bindTo": "mergeRecords"},
Visible: {"bindTo": "IsMergeRecordsButtonVisible"}
});
},
mergeRecords: function(mergeConfig) {
var items = this.getSelectedItems();
if (items && items.length > 1) {
var config = this.getMergeServiceConfig(items, mergeConfig);
this.callService(config, this.handleMergeServiceResponse.bind(this, items), this);
} else {
this.showInformationDialog(resources.localizableStrings.SelectMoreThanOneRowErrorMessage);
}
},
subscribeSandboxEvents: function() {
this.callParent(arguments);
const moduleId = this.getMergeModuleId();
this.sandbox.subscribe("Merge", function(config) {
this.mergeRecords(config);
}, this, [moduleId]);
},
init: function(callback, scope) {
this.callParent(arguments);
this.subscribeSandboxEvents();
}
}
};
});
3. Add a localized string for the button name with the code MergeRecordsButtonCaption.