Hi,
Hope someone can help me with replicating OrdersProducts in Quotes Section. I have tried that and while click on + icon products are not displaying.
Thank you.
Like
Dear Sushma,
The logic of the Product detail is implemented in OrderPage so if you page ss inherited from the BaseModulePage base page it will not work. You can investigate order page schema code to copy it to your new section or try the following example (the page should be modified according to the settings of your detail, otherwise it will not work):
define("UsrOrder3Page", ["EntityProductCountMixin"], function() {
return {
entitySchemaName: "Order",
messages: {
"GetOrderProductSummary": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.SUBSCRIBE
},
"UpdateOrderProductSummary": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.PUBLISH
},
},
mixins: {
EntityProductCountMixin: "Terrasoft.EntityProductCountMixin"
},
attributes: {
"Currency": {
dataValueType: Terrasoft.DataValueType.ENUM,
lookupListConfig: {
columns: ["Division", "ShortName", "Symbol"]
}
},
"AmountAndCurrency": {
dependencies: [
{
columns: ["Amount", "Currency"],
methodName: "updateOrderProductSummary"
}
]
},
"IsPaymentAmountLargerThanAmount": {
dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
value: false,
dependencies: [
{
columns: ["PaymentAmount", "Amount"],
methodName: "setIsPaymentAmountLargerThanAmount"
}
]
}
},
modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
details: /**SCHEMA_DETAILS*/{
ProductInProductsTab: {
schemaName: "OrderProductDetailV2",
entitySchemaName: "OrderProduct",
filter: {
masterColumn: "Id",
detailColumn: "Order"
},
subscriber: {methodName: "refreshAmount"},
defaultValues: {
Currency: {masterColumn: "Currency"},
CurrencyRate: {masterColumn: "CurrencyRate"}
}
}
}/**SCHEMA_DETAILS*/,
businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
methods: {
refreshAmount: function() {
this.updateAmount(function() {
this.updateOrderProductSummary();
}, this);
},
subscribeSandboxEvents: function() {
this.callParent(arguments);
this.sandbox.subscribe("GetOrderProductSummary", this.getProductSummaryConfig, this,
[this.getDetailId("ProductInProductsTab")]);
},
updateOrderProductSummary: function() {
this.sandbox.publish("UpdateOrderProductSummary", null,
[this.getDetailId("ProductInProductsTab"), this.getDetailId("ProductInResultsTab")]);
},
getProductSummaryConfig: function() {
var currency = this.get("Currency") || {};
return {
count: this.get("ProductCount"),
currency: currency.Symbol,
amount: this.get("Amount")
};
},
setIsPaymentAmountLargerThanAmount: function() {
var paymentAmount = this.get("PaymentAmount");
var amount = this.get("Amount");
var isLarger =
this.isNotEmpty(paymentAmount) &&
this.isNotEmpty(amount) &&
(paymentAmount > amount);
this.set("IsPaymentAmountLargerThanAmount", isLarger);
},
onSaved: function() {
this.callParent(arguments);
var config = arguments[arguments.length - 1];
if (config && config.isSilent) {
return;
}
this.updateAmountAfterSave("ProductInProductsTab",
function() {
this.updateDetail({detail: "ProductInResultsTab"});
this.updateOrderProductSummary();
},
this
);
},
loadEntity: function(primaryColumnValue, callback, scope) {
scope = scope || this;
this.callParent([primaryColumnValue, function() {
this.setIsPaymentAmountLargerThanAmount();
this.setProductCount(primaryColumnValue, callback, scope);
}, scope]);
},
getProductCountInEntityColumnName: function() {
return "ProductCount";
},
setColumnValues: function(entity) {
this.callParent(arguments);
this.updateProductsCount(entity);
},
modifyAmountESQ: function(esq) {
this.mixins.ProductEntryPageUtils.modifyAmountESQ.apply(this, arguments);
this.addProductsCountColumn(esq);
},
updateAmountColumnValues: function(entity) {
this.mixins.ProductEntryPageUtils.updateAmountColumnValues.apply(this, arguments);
this.updateProductsCount(entity);
},
addProductsCountColumn: function(esq) {
esq.addAggregationSchemaColumn("[OrderProduct:Order].Id",
this.Terrasoft.AggregationType.COUNT, "ProductCount");
},
updateProductsCount: function(entity) {
var countColumn = "ProductCount";
this.setColumnValue(countColumn, entity.get(countColumn), {preventValidation: true});
}
},
dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "ProductInProductsTab",
"values": {
"itemType": 2,
"markerValue": "added-detail"
},
"parentName": "Tab0686e409TabLabel", //detail placement
"propertyName": "items",
"index": 0
}
]/**SCHEMA_DIFF*/
};
});
sushma,
Can you please specify how it is not updated? Do you mean the currency that is specified in the price list?
sushma,
It is hard to find the reason of this error as it is a custom object and there is no information in the pop-up. Try to debug (
https://academy.creatio.com/documents/technic-sdk/7-15/client-code-debugging) the application using developer tools to locate what causes this error.
when trying to debug when i change
"Currency": {
dataValueType: Terrasoft.DataValueType.ENUM,
lookupListConfig: {
columns: ["Division", "ShortName", "Symbol"]
}
},
to "Currency": {
dataValueType: Terrasoft.DataValueType.LOOKUP,
lookupListConfig: {
columns: ["Division", "ShortName", "Symbol"]
}
},
Error is not coming as it says when updating there is mismatch with datatype of currency. But still detail is not updating when currency is changed and total amount is not updating based on sum of amounts of all products
sushma,
why are you trying to change currency to lookup type? It should remain ENUM