Hello!
I am trying to get the date field updated for multiple records using a custom Action.
I have referred to this article for it: Change of the field value of multiple records using custom action | Community Creatio
I have successfully created a pop up but, the update is not reflecting in the selected records.
I have also attached the screenshot of it and the code that I have used.
The code that I have used:
getSectionActions: function() {
actionMenuItems.addItem(this.getButtonMenuItem({
"Caption": {bindTo: "Resources.Strings.MultiplyChangeAction"},
"Click": {bindTo: "showDateInfo"},
"Enabled": {bindTo: "isCustomActionEnabled"}
}));
// Returning of the added section action collection.
return actionMenuItems;
},
showDateInfo: function() {
Terrasoft.utils.inputBox("Set Visit Date for update", function(result, arg) {
if (result === Terrasoft.MessageBoxButtons.YES.returnCode) {
var date = arg.date.value;
var autoIds = this.getSelectedItems();
this.updateDate(function(context, result) {
}, autoIds, date);
}
}, [{
className: "Terrasoft.Button",
caption: "OK",
returnCode: "yes"
}, "cancel"], this,
{
date: {
dataValueType: Terrasoft.DataValueType.DATE,
caption: "Visit Date",
customConfig: {
className: "Terrasoft.DateEdit",
height: "17px"
}
},
},
{
defaultButton: 0,
style: {
borderStyle: "ts-messagebox-border-style-blue ts-messagebox-border-no-header",
buttonStyle: "blue"
}
}
);
},
updateDate: function(callback, autoIds, date) {
var update = Ext.create("Terrasoft.UpdateQuery", {
rootSchemaName: "JFLFieldSales"
});
var filters = Terrasoft.createFilterGroup();
filters.logicalOperation = Terrasoft.LogicalOperatorType.OR;
autoIds.forEach(function(item) {
var productIdFilter = update.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
"Id", item);
filters.add("ProductIdFilter" + item, productIdFilter);
}, this);
update.filters.add(filters);
if (date) {
update.setParameterValue("JFLAssignmentDate", date, Terrasoft.DataValueType.Date);
// update.setParameterValue("JFLAssignmentDate", time, Terrasoft.DataValueType.Date);
}
update.execute(function(result) {
callback.call(this, result);
}, this);
}
}
};
});
I have also attached full code of the schema as a file.
Also, please let me know if I can update the time also as the field in the record is of type DATE_TIME.