Values disappearing on click of a record after added from multiselect lookup.

Hi Team,

 

I have implemented the Multiselect lookup detail and Editable detail list from the following Articles to the same detail.

MultiSelect Lookup - https://academy.creatio.com/documents/technic-sdk/7-16/creating-detail-…

Editable Detail List - https://academy.creatio.com/documents/technic-sdk/7-15/adding-detail-ed…

 

Step 1 : I'm selecting a record from Multiselct and it adds to the detail.

Step 2 : I'm clicking on the added row but it becomes empty as shown in the attachment.

 

Note:

It is working when i refreshed the page,.

 

Thanks in advance!

 

Regards,

Bhoobalan P.

 

Image 1 : Before adding data from multiselct lookup.

 

Image 2 : After adding data from Multiselct lookup.

 

Image 3 :  After clicking on the added record.

Like 0

Like

12 comments
Best reply

Bhoobalan Palanivelu,

Please use the following updated code that will perfectly work and won;t return an error upon record adding:

// Defining schema and setting its dependencies from other modules.
define("UsrCourierServiceDetail", ["BusinessRulesApplierV2","ConfigurationGrid", "ConfigurationGridGenerator",
    "ConfigurationEnums","ConfigurationGridUtilities",
    "css!UsrCourierServiceDetailCSS"],function(configurationEnums) {
        return {
            // Name of the detail object schema.
            entitySchemaName: "UsrCourierService",
             attributes: {
            // Determines whether the editing is enabled.
            "IsEditable": {
                // Data type — logic.
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                // Attribute type — virtual column of the view model.
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                // Set value.
                value: true
            }
        },
 
 
        // Used mixins.
        mixins: {
            ConfigurationGridUtilities: "Terrasoft.ConfigurationGridUtilities"
        },
            // Detail schema methods.
            methods: {
 
              //Returns columns selected by query.
                getGridDataColumns: function() {
                    return {
                        "Id": {path: "Id"},
                        "Document": {path: "UsrDocument"},
                        "Document.Number": {path: "UsrDocument.Number"}
                    };
                },
 
                //Configures and displays modal lookup window.
                openDocumentLookup: function() {
                    //Configuration object
                    var config = {
                        // Name of the object schema whose records will be displayed in the lookup.
                        entitySchemaName: "Document",
                        // Multiple selection option.
                        multiSelect: true,
                        // Columns used in the lookup, e.g., for sorting.
                        columns: ["Number", "Date", "Type"]
                    };
                    var OrderId = this.get("MasterRecordId");
                    if (this.Ext.isEmpty(OrderId)) {
                        return;
                    }
                    // The [EntitySchemaQuery] class instance.
                    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                        // Setting up the root schema.
                        rootSchemaName: this.entitySchemaName
                    });
                    // Adding the [Id] column.
                    esq.addColumn("Id");
                    // Adding the [Id] column for the [Document] schema.
                    esq.addColumn("Document.Id", "DocumentId");
                    // Creating and adding filters to query collection.
                    esq.filters.add("filterOrder", this.Terrasoft.createColumnFilterWithParameter(
                        this.Terrasoft.ComparisonType.EQUAL, "UsrOrder", OrderId));
                    // Receiving the whole record collection and its display in the modal lookup window.
                    esq.getEntityCollection(function(result) {
                        var existsDocumentsCollection = [];
                        if (result.success) {
                            result.collection.each(function(item) {
                                existsDocumentsCollection.push(item.get("DocumentId"));
                            });
                        }
                        // Adding filter to the configuration object.
                        if (existsDocumentsCollection.length > 0) {
                            var existsFilter = this.Terrasoft.createColumnInFilterWithParameters("Id",
                                existsDocumentsCollection);
                            existsFilter.comparisonType = this.Terrasoft.ComparisonType.NOT_EQUAL;
                            existsFilter.Name = "existsFilter";
                            config.filters = existsFilter;
                        }
                        // Call of the modal lookup window
                        this.openLookup(config, this.addCallBack, this);
                    }, this);
                },
 
                // Event handler of saving the edit page.
                onCardSaved: function() {
                    this.openDocumentLookup();
                },
 
                //Opens the document lookup if the order edit page has been saved.
                addRecord: function() {
                    var masterCardState = this.sandbox.publish("GetCardState", null, [this.sandbox.id]);
                    var isNewRecord = (masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.ADD ||
                    masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.COPY);
                    if (isNewRecord === true) {
                        var args = {
                            isSilent: true,
                            messageTags: [this.sandbox.id]
                        };
                        this.sandbox.publish("SaveRecord", args, [this.sandbox.id]);
                        return;
                    }
                    this.openDocumentLookup();
                },
 
                // Adding the selected products.
                addCallBack: function(args) {
                    // Class instance of the BatchQuery package query.
                    var bq = this.Ext.create("Terrasoft.BatchQuery");
                    var OrderId = this.get("MasterRecordId");
                    // Collection of the selected documents from the lookup.
                    this.selectedRows = args.selectedRows.getItems();
                    // Collection passed over to query.
                    this.selectedItems = [];
                    // Copying the necessary data.
                    this.selectedRows.forEach(function(item) {
                        item.OrderId = OrderId;
                        item.DocumentId = item.value;
                        bq.add(this.getDocumentInsertQuery(item));
                        this.selectedItems.push(item.value);
                    }, this);
                    // Executing the package query if it is not empty.
                    if (bq.queries.length) {
                        this.showBodyMask.call(this);
                        bq.execute(this.onDocumentInsert, this);
                    }
                },
 
                //Returns query for adding the current object.
                getDocumentInsertQuery: function(item) {
                    var insert = Ext.create("Terrasoft.InsertQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    insert.setParameterValue("UsrOrder", item.OrderId, this.Terrasoft.DataValueType.GUID);
                    insert.setParameterValue("UsrDocument", item.DocumentId, this.Terrasoft.DataValueType.GUID);
                    return insert;
                },
 
                //Method called when adding records to the detail record list.
                onDocumentInsert: function(response) {
                    this.hideBodyMask.call(this);
                    this.beforeLoadGridData();
                    var filterCollection = [];
                    response.queryResults.forEach(function(item) {
                        filterCollection.push(item.id);
                    });
                    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    this.initQueryColumns(esq);
                    esq.filters.add("recordId", Terrasoft.createColumnInFilterWithParameters("Id", filterCollection));
                    // Create viewmodel for new items
                    esq.on("createviewmodel", this.createViewModel, this);
                    esq.getEntityCollection(function(response) {
                        this.afterLoadGridData();
                        if (response.success) {
                            var responseCollection = response.collection;
                            this.prepareResponseCollection(responseCollection);
                            this.getGridData().loadAll(responseCollection);
                        }
                    }, this);
 
                },
 
                // Method called when deleting records from the detail record list.
                deleteRecords: function() {
                    var selectedRows = this.getSelectedItems();
                    if (selectedRows.length > 0) {
                        this.set("SelectedRows", selectedRows);
                        this.callParent(arguments);
                    }
                },
 
                // Hide the [Copy] menu option.
                getCopyRecordMenuItem: Terrasoft.emptyFn,
                 // Hide the [Edit] menu option.
                getEditRecordMenuItem: Terrasoft.emptyFn,
                // Returns the default filter column name.
                getFilterDefaultColumnName: function() {
                    return "UsrDocument";
                }
            },
            // Modification array.
            diff: /**SCHEMA_DIFF*/[
                {
                // Operation type — merging.
                "operation": "merge",
                // Name of the schema element, with which the action is performed.
                "name": "DataGrid",
                // Object, whose properties will be joined with the schema element properties.
                "values": {
                    // Class name
                    "className": "Terrasoft.ConfigurationGrid",
                    // View generator must generate only part of view.
                    "generator": "ConfigurationGridGenerator.generatePartial",
                    // Binding the edit elements configuration obtaining event
                    // of the active page to handler method.
                    "generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},
                    // Binding the active record changing event to handler method.
                    "changeRow": {"bindTo": "changeRow"},
                    // Binding the record selection cancellation event to handler method.
                    "unSelectRow": {"bindTo": "unSelectRow"},
                    // Binding of the list click event to handler method.
                    "onGridClick": {"bindTo": "onGridClick"},
                    // Actions performed with active record.
                    "activeRowActions": [
                        // [Save] action setup.
                        {
                            // Class name of the control element, with which the action is connected.
                            "className": "Terrasoft.Button",
                            // Display style — transparent button.
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            // Tag.
                            "tag": "save",
                            // Marker value.
                            "markerValue": "save",
                            // Binding button image.
                            "imageConfig": {"bindTo": "Resources.Images.SaveIcon"}
                        },
                        // [Cancel] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "cancel",
                            "markerValue": "cancel",
                            "imageConfig": {"bindTo": "Resources.Images.CancelIcon"}
                        },
                        // [Delete] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "remove",
                            "markerValue": "remove",
                            "imageConfig": {"bindTo": "Resources.Images.RemoveIcon"}
                        }
                    ],
                    // Binding to method that initializes subscription to events
                    // of clicking buttons in the active row.
                    "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},
                    // Binding the active record action completion event to handler method.
                    "activeRowAction": {"bindTo": "onActiveRowAction"},
                    // Identifies whether multiple records can be selected.
                    "multiSelect": {"bindTo": "MultiSelect"}
                }
            },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "DataGrid",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                        "rowDataItemMarkerColumnName": "UsrDocument"
                    }
                },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "AddRecordButton",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                    	"click":{"bindTo":"addRecord"},
                        "visible": {"bindTo": "getToolsVisible"}
                    }
                }
            ]/**SCHEMA_DIFF*/
        };
    }
);

The trick is in the esq.on("createviewmodel", this.createViewModel, this); string in the onDocumentInsert method.

 

Best regards,

Oscar

Hi,

 

Please provide us with the error message that you receive upon clicking the record, the screenshot of the detail configuration (name, title, parent object) and also with the code of the detail itself.

 

Best regards,

Oscar

Oscar Dylan,

Thanks for the response!



I have provided the code of deatil itself where both muliselect and editable list is implemented and the error screenshot attachment.

 



 

define("UsrCourierCertDetail", ["ConfigurationEnums","ConfigurationGrid", "ConfigurationGridGenerator",

    "ConfigurationGridUtilities"],

    function(configurationEnums) {

        return {

            // Name of the detail object schema.

            entitySchemaName: "UsrCourierCertInOrder",

             attributes: {

            // Determines whether the editing is enabled.

            "IsEditable": {

                // Data type — logic.

                dataValueType: Terrasoft.DataValueType.BOOLEAN,

                // Attribute type — virtual column of the view model.

                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

                // Set value.

                value: true

            }

        },

       

        

        // Used mixins.

        mixins: {

            ConfigurationGridUtilities: "Terrasoft.ConfigurationGridUtilities"

        },

            // Detail schema methods.

            methods: {

                        

              //Returns columns selected by query.

                getGridDataColumns: function() {

                    return {

                        "Id": {path: "Id"},

                        "Document": {path: "UsrDocument"},

                        "Document.Number": {path: "UsrDocument.Number"}

                    };

                },

                //Configures and displays modal lookup window.

                openDocumentLookup: function() {

                    //Configuration object

                    var config = {

                        // Name of the object schema whose records will be displayed in the lookup.

                        entitySchemaName: "Document",

                        // Multiple selection option.

                        multiSelect: true,

                        // Columns used in the lookup, e.g., for sorting.

                        columns: ["Number", "Date", "Type"]

                    };

                    var OrderId = this.get("MasterRecordId");

                    if (this.Ext.isEmpty(OrderId)) {

                        return;

                    }

                    // The [EntitySchemaQuery] class instance.

                    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

                        // Setting up the root schema.

                        rootSchemaName: this.entitySchemaName

                    });

                    // Adding the [Id] column.

                    esq.addColumn("Id");

                    // Adding the [Id] column for the [Document] schema.

                    esq.addColumn("Document.Id", "DocumentId");

                    // Creating and adding filters to query collection.

                    esq.filters.add("filterOrder", this.Terrasoft.createColumnFilterWithParameter(

                        this.Terrasoft.ComparisonType.EQUAL, "UsrOrder", OrderId));

                    // Receiving the whole record collection and its display in the modal lookup window.

                    esq.getEntityCollection(function(result) {

                        var existsDocumentsCollection = [];

                        if (result.success) {

                            result.collection.each(function(item) {

                                existsDocumentsCollection.push(item.get("DocumentId"));

                            });

                        }

                        // Adding filter to the configuration object.

                        if (existsDocumentsCollection.length > 0) {

                            var existsFilter = this.Terrasoft.createColumnInFilterWithParameters("Id",

                                existsDocumentsCollection);

                            existsFilter.comparisonType = this.Terrasoft.ComparisonType.NOT_EQUAL;

                            existsFilter.Name = "existsFilter";

                            config.filters = existsFilter;

                        }

                        // Call of the modal lookup window

                        this.openLookup(config, this.addCallBack, this);

                    }, this);

                },

                // Event handler of saving the edit page.

                onCardSaved: function() {

                    this.openDocumentLookup();

                },

                //Opens the document lookup if the order edit page has been saved.

                addRecord: function() {

                    var masterCardState = this.sandbox.publish("GetCardState", null, [this.sandbox.id]);

                    var isNewRecord = (masterCardState.state === configurationEnums.CardStateV2.ADD ||

                    masterCardState.state === configurationEnums.CardStateV2.COPY);

                    if (isNewRecord === true) {

                        var args = {

                            isSilent: true,

                            messageTags: [this.sandbox.id]

                        };

                        this.sandbox.publish("SaveRecord", args, [this.sandbox.id]);

                        return;

                    }

                    this.openDocumentLookup();

                },

                // Adding the selected products.

                addCallBack: function(args) {

                    // Class instance of the BatchQuery package query.

                    var bq = this.Ext.create("Terrasoft.BatchQuery");

                    var OrderId = this.get("MasterRecordId");

                    // Collection of the selected documents from the lookup.

                    this.selectedRows = args.selectedRows.getItems();

                    // Collection passed over to query.

                    this.selectedItems = [];

                    // Copying the necessary data.

                    this.selectedRows.forEach(function(item) {

                        item.OrderId = OrderId;

                        item.DocumentId = item.value;

                        bq.add(this.getDocumentInsertQuery(item));

                        this.selectedItems.push(item.value);

                    }, this);

                    // Executing the package query if it is not empty.

                    if (bq.queries.length) {

                        this.showBodyMask.call(this);

                        bq.execute(this.onDocumentInsert, this);

                    }

                },

                //Returns query for adding the current object.

                getDocumentInsertQuery: function(item) {

                    var insert = Ext.create("Terrasoft.InsertQuery", {

                        rootSchemaName: this.entitySchemaName

                    });

                    insert.setParameterValue("UsrOrder", item.OrderId, this.Terrasoft.DataValueType.GUID);

                    insert.setParameterValue("UsrDocument", item.DocumentId, this.Terrasoft.DataValueType.GUID);

                    return insert;

                },

                //Method called when adding records to the detail record list.

                onDocumentInsert: function(response) {

                    this.hideBodyMask.call(this);

                    this.beforeLoadGridData();

                    var filterCollection = [];

                    response.queryResults.forEach(function(item) {

                        filterCollection.push(item.id);

                    });

                    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {

                        rootSchemaName: this.entitySchemaName

                    });

                    this.initQueryColumns(esq);

                    esq.filters.add("recordId", Terrasoft.createColumnInFilterWithParameters("Id", filterCollection));

                    esq.getEntityCollection(function(response) {

                        this.afterLoadGridData();

                        if (response.success) {

                            var responseCollection = response.collection;

                            this.prepareResponseCollection(responseCollection);

                            this.getGridData().loadAll(responseCollection);

                        }

                    }, this);

                   

                },

                // Method called when deleting records from the detail record list.

                deleteRecords: function() {

                    var selectedRows = this.getSelectedItems();

                    if (selectedRows.length > 0) {

                        this.set("SelectedRows", selectedRows);

                        this.callParent(arguments);

                    }

                },

                // Hide the [Copy] menu option.

                getCopyRecordMenuItem: Terrasoft.emptyFn,

                 // Hide the [Edit] menu option.

                getEditRecordMenuItem: Terrasoft.emptyFn,

                // Returns the default filter column name.

                getFilterDefaultColumnName: function() {

                    return "UsrDocument";

                }

            },

            // Modification array.

            diff: /**SCHEMA_DIFF*/[

                {

                // Operation type — merging.

                "operation": "merge",

                // Name of the schema element, with which the action is performed.

                "name": "DataGrid",

                // Object, whose properties will be joined with the schema element properties.

                "values": {

                    // Class name

                    "className": "Terrasoft.ConfigurationGrid",

                    // View generator must generate only part of view.

                    "generator": "ConfigurationGridGenerator.generatePartial",

                    // Binding the edit elements configuration obtaining event

                    // of the active page to handler method.

                    "generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},

                    // Binding the active record changing event to handler method.

                    "changeRow": {"bindTo": "changeRow"},

                    // Binding the record selection cancellation event to handler method.

                    "unSelectRow": {"bindTo": "unSelectRow"},

                    // Binding of the list click event to handler method.

                    "onGridClick": {"bindTo": "onGridClick"},

                    // Actions performed with active record.

                    "activeRowActions": [

                        // [Save] action setup.

                        {

                            // Class name of the control element, with which the action is connected.

                            "className": "Terrasoft.Button",

                            // Display style — transparent button.

                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,

                            // Tag.

                            "tag": "save",

                            // Marker value.

                            "markerValue": "save",

                            // Binding button image.

                            "imageConfig": {"bindTo": "Resources.Images.SaveIcon"}

                        },

                        // [Cancel] action setup.

                        {

                            "className": "Terrasoft.Button",

                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,

                            "tag": "cancel",

                            "markerValue": "cancel",

                            "imageConfig": {"bindTo": "Resources.Images.CancelIcon"}

                        },

                        // [Delete] action setup.

                        {

                            "className": "Terrasoft.Button",

                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,

                            "tag": "remove",

                            "markerValue": "remove",

                            "imageConfig": {"bindTo": "Resources.Images.RemoveIcon"}

                        }

                    ],

                    // Binding to method that initializes subscription to events

                    // of clicking buttons in the active row.

                    "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},

                    // Binding the active record action completion event to handler method.

                    "activeRowAction": {"bindTo": "onActiveRowAction"},

                    // Identifies whether multiple records can be selected.

                    "multiSelect": {"bindTo": "MultiSelect"}

                }

            },

                {

                    // Operation type - merging.

                    "operation": "merge",

                    // Name of the schema element under operation.

                    "name": "DataGrid",

                    // The object, whose properties will be combined with the schema element properties.

                    "values": {

                        "rowDataItemMarkerColumnName": "UsrDocument"

                    }

                },

                {

                    // Operation type - merging.

                    "operation": "merge",

                    // Name of the schema element under operation.

                    "name": "AddRecordButton",

                    // The object, whose properties will be combined with the schema element properties.

                    "values": {

                        "visible": {"bindTo": "getToolsVisible"}

                    }

                }

            ]/**SCHEMA_DIFF*/

        };

    }

);

Bhoobalan Palanivelu,

and can you please provide us with the screenshot of the parent object for the detail? Like this one:

Thank you!

 

Best regards,

Oscar

Oscar Dylan,

 

Please find the attached screenshot!

 

Bhoobalan Palanivelu,

 

Thank you! I've deployed the same code and object on my end and the detail works (also I modified the code a little bit since it returned an error on my end because of this part

 var isNewRecord = (masterCardState.state === configurationEnums.CardStateV2.ADD ||
                    masterCardState.state === configurationEnums.CardStateV2.COPY);

):

// Defining schema and setting its dependencies from other modules.
define("UsrCourierServiceDetail", ["BusinessRulesApplierV2","ConfigurationGrid", "ConfigurationGridGenerator",
    "ConfigurationEnums","ConfigurationGridUtilities",
    "css!UsrCourierServiceDetailCSS"],function(configurationEnums) {
        return {
            // Name of the detail object schema.
            entitySchemaName: "UsrCourierService",
             attributes: {
            // Determines whether the editing is enabled.
            "IsEditable": {
                // Data type — logic.
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                // Attribute type — virtual column of the view model.
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                // Set value.
                value: true
            }
        },
 
 
        // Used mixins.
        mixins: {
            ConfigurationGridUtilities: "Terrasoft.ConfigurationGridUtilities"
        },
            // Detail schema methods.
            methods: {
 
              //Returns columns selected by query.
                getGridDataColumns: function() {
                    return {
                        "Id": {path: "Id"},
                        "Document": {path: "UsrDocument"},
                        "Document.Number": {path: "UsrDocument.Number"}
                    };
                },
 
                //Configures and displays modal lookup window.
                openDocumentLookup: function() {
                    //Configuration object
                    var config = {
                        // Name of the object schema whose records will be displayed in the lookup.
                        entitySchemaName: "Document",
                        // Multiple selection option.
                        multiSelect: true,
                        // Columns used in the lookup, e.g., for sorting.
                        columns: ["Number", "Date", "Type"]
                    };
                    var OrderId = this.get("MasterRecordId");
                    if (this.Ext.isEmpty(OrderId)) {
                        return;
                    }
                    // The [EntitySchemaQuery] class instance.
                    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                        // Setting up the root schema.
                        rootSchemaName: this.entitySchemaName
                    });
                    // Adding the [Id] column.
                    esq.addColumn("Id");
                    // Adding the [Id] column for the [Document] schema.
                    esq.addColumn("Document.Id", "DocumentId");
                    // Creating and adding filters to query collection.
                    esq.filters.add("filterOrder", this.Terrasoft.createColumnFilterWithParameter(
                        this.Terrasoft.ComparisonType.EQUAL, "UsrOrder", OrderId));
                    // Receiving the whole record collection and its display in the modal lookup window.
                    esq.getEntityCollection(function(result) {
                        var existsDocumentsCollection = [];
                        if (result.success) {
                            result.collection.each(function(item) {
                                existsDocumentsCollection.push(item.get("DocumentId"));
                            });
                        }
                        // Adding filter to the configuration object.
                        if (existsDocumentsCollection.length > 0) {
                            var existsFilter = this.Terrasoft.createColumnInFilterWithParameters("Id",
                                existsDocumentsCollection);
                            existsFilter.comparisonType = this.Terrasoft.ComparisonType.NOT_EQUAL;
                            existsFilter.Name = "existsFilter";
                            config.filters = existsFilter;
                        }
                        // Call of the modal lookup window
                        this.openLookup(config, this.addCallBack, this);
                    }, this);
                },
 
                // Event handler of saving the edit page.
                onCardSaved: function() {
                    this.openDocumentLookup();
                },
 
                //Opens the document lookup if the order edit page has been saved.
                addRecord: function() {
                    var masterCardState = this.sandbox.publish("GetCardState", null, [this.sandbox.id]);
                    var isNewRecord = (masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.ADD ||
                    masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.COPY);
                    if (isNewRecord === true) {
                        var args = {
                            isSilent: true,
                            messageTags: [this.sandbox.id]
                        };
                        this.sandbox.publish("SaveRecord", args, [this.sandbox.id]);
                        return;
                    }
                    this.openDocumentLookup();
                },
 
                // Adding the selected products.
                addCallBack: function(args) {
                    // Class instance of the BatchQuery package query.
                    var bq = this.Ext.create("Terrasoft.BatchQuery");
                    var OrderId = this.get("MasterRecordId");
                    // Collection of the selected documents from the lookup.
                    this.selectedRows = args.selectedRows.getItems();
                    // Collection passed over to query.
                    this.selectedItems = [];
                    // Copying the necessary data.
                    this.selectedRows.forEach(function(item) {
                        item.OrderId = OrderId;
                        item.DocumentId = item.value;
                        bq.add(this.getDocumentInsertQuery(item));
                        this.selectedItems.push(item.value);
                    }, this);
                    // Executing the package query if it is not empty.
                    if (bq.queries.length) {
                        this.showBodyMask.call(this);
                        bq.execute(this.onDocumentInsert, this);
                    }
                },
 
                //Returns query for adding the current object.
                getDocumentInsertQuery: function(item) {
                    var insert = Ext.create("Terrasoft.InsertQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    insert.setParameterValue("UsrOrder", item.OrderId, this.Terrasoft.DataValueType.GUID);
                    insert.setParameterValue("UsrDocument", item.DocumentId, this.Terrasoft.DataValueType.GUID);
                    return insert;
                },
 
                //Method called when adding records to the detail record list.
                onDocumentInsert: function(response) {
                    this.hideBodyMask.call(this);
                    this.beforeLoadGridData();
                    var filterCollection = [];
                    response.queryResults.forEach(function(item) {
                        filterCollection.push(item.id);
                    });
                    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    this.initQueryColumns(esq);
                    esq.filters.add("recordId", Terrasoft.createColumnInFilterWithParameters("Id", filterCollection));
                    esq.getEntityCollection(function(response) {
                        this.afterLoadGridData();
                        if (response.success) {
                            var responseCollection = response.collection;
                            this.prepareResponseCollection(responseCollection);
                            this.getGridData().loadAll(responseCollection);
                        }
                    }, this);
 
                },
 
                // Method called when deleting records from the detail record list.
                deleteRecords: function() {
                    var selectedRows = this.getSelectedItems();
                    if (selectedRows.length > 0) {
                        this.set("SelectedRows", selectedRows);
                        this.callParent(arguments);
                    }
                },
 
                // Hide the [Copy] menu option.
                getCopyRecordMenuItem: Terrasoft.emptyFn,
                 // Hide the [Edit] menu option.
                getEditRecordMenuItem: Terrasoft.emptyFn,
                // Returns the default filter column name.
                getFilterDefaultColumnName: function() {
                    return "UsrDocument";
                }
            },
            // Modification array.
            diff: /**SCHEMA_DIFF*/[
                {
                // Operation type — merging.
                "operation": "merge",
                // Name of the schema element, with which the action is performed.
                "name": "DataGrid",
                // Object, whose properties will be joined with the schema element properties.
                "values": {
                    // Class name
                    "className": "Terrasoft.ConfigurationGrid",
                    // View generator must generate only part of view.
                    "generator": "ConfigurationGridGenerator.generatePartial",
                    // Binding the edit elements configuration obtaining event
                    // of the active page to handler method.
                    "generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},
                    // Binding the active record changing event to handler method.
                    "changeRow": {"bindTo": "changeRow"},
                    // Binding the record selection cancellation event to handler method.
                    "unSelectRow": {"bindTo": "unSelectRow"},
                    // Binding of the list click event to handler method.
                    "onGridClick": {"bindTo": "onGridClick"},
                    // Actions performed with active record.
                    "activeRowActions": [
                        // [Save] action setup.
                        {
                            // Class name of the control element, with which the action is connected.
                            "className": "Terrasoft.Button",
                            // Display style — transparent button.
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            // Tag.
                            "tag": "save",
                            // Marker value.
                            "markerValue": "save",
                            // Binding button image.
                            "imageConfig": {"bindTo": "Resources.Images.SaveIcon"}
                        },
                        // [Cancel] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "cancel",
                            "markerValue": "cancel",
                            "imageConfig": {"bindTo": "Resources.Images.CancelIcon"}
                        },
                        // [Delete] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "remove",
                            "markerValue": "remove",
                            "imageConfig": {"bindTo": "Resources.Images.RemoveIcon"}
                        }
                    ],
                    // Binding to method that initializes subscription to events
                    // of clicking buttons in the active row.
                    "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},
                    // Binding the active record action completion event to handler method.
                    "activeRowAction": {"bindTo": "onActiveRowAction"},
                    // Identifies whether multiple records can be selected.
                    "multiSelect": {"bindTo": "MultiSelect"}
                }
            },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "DataGrid",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                        "rowDataItemMarkerColumnName": "UsrDocument"
                    }
                },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "AddRecordButton",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                    	"click":{"bindTo":"addRecord"},
                        "visible": {"bindTo": "getToolsVisible"}
                    }
                }
            ]/**SCHEMA_DIFF*/
        };
    }
);

And also the parent object is "Base schema - Detail with list ( NUI )". Records can be added on my end and please copy the code that I used on my end and use it on your side. Also try recreating the detail from scratch. Also don't forget to check if your object (that is specified in the "entitySchemaName" part of the code).

 

Best regards,

Oscar

Oscar Dylan,

 

Thanks for the response.

 

I can add the records, but when i click on the added record, the record values get disappearing as shown in the image.

 

Thanks in advance!

 

After Adding the record:

 

After Clicking the Added Record:



 

Bhoobalan Palanivelu,

 

Please perform all the steps that I've mentioned in the previous email. The record doesn't disappear on our end when clicking on the detail record. Also you may need to recreate the detail from scratch. Please see the screenshot of the detail from our end:

Best regards,

Oscar

Oscar Dylan,

Yes, I tried the same as you suggested.

 

This happens for the recently added record.

when recently added record is selected this issue persists.

Step 1 : Click on + sign

Step 2 : Choose a record from multi select and click on select.

Step 3: The record is added in courier service detail.

Step 4 : click on the same record that is selected during + sign click and selected one. (The values disapperaing in this case).



After refresh it is fine.

Bhoobalan Palanivelu,

 

Yes indeed, using this scenario the issue can be reproduced. Looking into it now.

 

Best regards,

Oscar

Oscar Dylan,

Thanks much for taking this into consideration. 

 

Bhoobalan Palanivelu,

Please use the following updated code that will perfectly work and won;t return an error upon record adding:

// Defining schema and setting its dependencies from other modules.
define("UsrCourierServiceDetail", ["BusinessRulesApplierV2","ConfigurationGrid", "ConfigurationGridGenerator",
    "ConfigurationEnums","ConfigurationGridUtilities",
    "css!UsrCourierServiceDetailCSS"],function(configurationEnums) {
        return {
            // Name of the detail object schema.
            entitySchemaName: "UsrCourierService",
             attributes: {
            // Determines whether the editing is enabled.
            "IsEditable": {
                // Data type — logic.
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                // Attribute type — virtual column of the view model.
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                // Set value.
                value: true
            }
        },
 
 
        // Used mixins.
        mixins: {
            ConfigurationGridUtilities: "Terrasoft.ConfigurationGridUtilities"
        },
            // Detail schema methods.
            methods: {
 
              //Returns columns selected by query.
                getGridDataColumns: function() {
                    return {
                        "Id": {path: "Id"},
                        "Document": {path: "UsrDocument"},
                        "Document.Number": {path: "UsrDocument.Number"}
                    };
                },
 
                //Configures and displays modal lookup window.
                openDocumentLookup: function() {
                    //Configuration object
                    var config = {
                        // Name of the object schema whose records will be displayed in the lookup.
                        entitySchemaName: "Document",
                        // Multiple selection option.
                        multiSelect: true,
                        // Columns used in the lookup, e.g., for sorting.
                        columns: ["Number", "Date", "Type"]
                    };
                    var OrderId = this.get("MasterRecordId");
                    if (this.Ext.isEmpty(OrderId)) {
                        return;
                    }
                    // The [EntitySchemaQuery] class instance.
                    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                        // Setting up the root schema.
                        rootSchemaName: this.entitySchemaName
                    });
                    // Adding the [Id] column.
                    esq.addColumn("Id");
                    // Adding the [Id] column for the [Document] schema.
                    esq.addColumn("Document.Id", "DocumentId");
                    // Creating and adding filters to query collection.
                    esq.filters.add("filterOrder", this.Terrasoft.createColumnFilterWithParameter(
                        this.Terrasoft.ComparisonType.EQUAL, "UsrOrder", OrderId));
                    // Receiving the whole record collection and its display in the modal lookup window.
                    esq.getEntityCollection(function(result) {
                        var existsDocumentsCollection = [];
                        if (result.success) {
                            result.collection.each(function(item) {
                                existsDocumentsCollection.push(item.get("DocumentId"));
                            });
                        }
                        // Adding filter to the configuration object.
                        if (existsDocumentsCollection.length > 0) {
                            var existsFilter = this.Terrasoft.createColumnInFilterWithParameters("Id",
                                existsDocumentsCollection);
                            existsFilter.comparisonType = this.Terrasoft.ComparisonType.NOT_EQUAL;
                            existsFilter.Name = "existsFilter";
                            config.filters = existsFilter;
                        }
                        // Call of the modal lookup window
                        this.openLookup(config, this.addCallBack, this);
                    }, this);
                },
 
                // Event handler of saving the edit page.
                onCardSaved: function() {
                    this.openDocumentLookup();
                },
 
                //Opens the document lookup if the order edit page has been saved.
                addRecord: function() {
                    var masterCardState = this.sandbox.publish("GetCardState", null, [this.sandbox.id]);
                    var isNewRecord = (masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.ADD ||
                    masterCardState.state === Terrasoft.ConfigurationEnums.CardOperation.COPY);
                    if (isNewRecord === true) {
                        var args = {
                            isSilent: true,
                            messageTags: [this.sandbox.id]
                        };
                        this.sandbox.publish("SaveRecord", args, [this.sandbox.id]);
                        return;
                    }
                    this.openDocumentLookup();
                },
 
                // Adding the selected products.
                addCallBack: function(args) {
                    // Class instance of the BatchQuery package query.
                    var bq = this.Ext.create("Terrasoft.BatchQuery");
                    var OrderId = this.get("MasterRecordId");
                    // Collection of the selected documents from the lookup.
                    this.selectedRows = args.selectedRows.getItems();
                    // Collection passed over to query.
                    this.selectedItems = [];
                    // Copying the necessary data.
                    this.selectedRows.forEach(function(item) {
                        item.OrderId = OrderId;
                        item.DocumentId = item.value;
                        bq.add(this.getDocumentInsertQuery(item));
                        this.selectedItems.push(item.value);
                    }, this);
                    // Executing the package query if it is not empty.
                    if (bq.queries.length) {
                        this.showBodyMask.call(this);
                        bq.execute(this.onDocumentInsert, this);
                    }
                },
 
                //Returns query for adding the current object.
                getDocumentInsertQuery: function(item) {
                    var insert = Ext.create("Terrasoft.InsertQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    insert.setParameterValue("UsrOrder", item.OrderId, this.Terrasoft.DataValueType.GUID);
                    insert.setParameterValue("UsrDocument", item.DocumentId, this.Terrasoft.DataValueType.GUID);
                    return insert;
                },
 
                //Method called when adding records to the detail record list.
                onDocumentInsert: function(response) {
                    this.hideBodyMask.call(this);
                    this.beforeLoadGridData();
                    var filterCollection = [];
                    response.queryResults.forEach(function(item) {
                        filterCollection.push(item.id);
                    });
                    var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: this.entitySchemaName
                    });
                    this.initQueryColumns(esq);
                    esq.filters.add("recordId", Terrasoft.createColumnInFilterWithParameters("Id", filterCollection));
                    // Create viewmodel for new items
                    esq.on("createviewmodel", this.createViewModel, this);
                    esq.getEntityCollection(function(response) {
                        this.afterLoadGridData();
                        if (response.success) {
                            var responseCollection = response.collection;
                            this.prepareResponseCollection(responseCollection);
                            this.getGridData().loadAll(responseCollection);
                        }
                    }, this);
 
                },
 
                // Method called when deleting records from the detail record list.
                deleteRecords: function() {
                    var selectedRows = this.getSelectedItems();
                    if (selectedRows.length > 0) {
                        this.set("SelectedRows", selectedRows);
                        this.callParent(arguments);
                    }
                },
 
                // Hide the [Copy] menu option.
                getCopyRecordMenuItem: Terrasoft.emptyFn,
                 // Hide the [Edit] menu option.
                getEditRecordMenuItem: Terrasoft.emptyFn,
                // Returns the default filter column name.
                getFilterDefaultColumnName: function() {
                    return "UsrDocument";
                }
            },
            // Modification array.
            diff: /**SCHEMA_DIFF*/[
                {
                // Operation type — merging.
                "operation": "merge",
                // Name of the schema element, with which the action is performed.
                "name": "DataGrid",
                // Object, whose properties will be joined with the schema element properties.
                "values": {
                    // Class name
                    "className": "Terrasoft.ConfigurationGrid",
                    // View generator must generate only part of view.
                    "generator": "ConfigurationGridGenerator.generatePartial",
                    // Binding the edit elements configuration obtaining event
                    // of the active page to handler method.
                    "generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},
                    // Binding the active record changing event to handler method.
                    "changeRow": {"bindTo": "changeRow"},
                    // Binding the record selection cancellation event to handler method.
                    "unSelectRow": {"bindTo": "unSelectRow"},
                    // Binding of the list click event to handler method.
                    "onGridClick": {"bindTo": "onGridClick"},
                    // Actions performed with active record.
                    "activeRowActions": [
                        // [Save] action setup.
                        {
                            // Class name of the control element, with which the action is connected.
                            "className": "Terrasoft.Button",
                            // Display style — transparent button.
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            // Tag.
                            "tag": "save",
                            // Marker value.
                            "markerValue": "save",
                            // Binding button image.
                            "imageConfig": {"bindTo": "Resources.Images.SaveIcon"}
                        },
                        // [Cancel] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "cancel",
                            "markerValue": "cancel",
                            "imageConfig": {"bindTo": "Resources.Images.CancelIcon"}
                        },
                        // [Delete] action setup.
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "remove",
                            "markerValue": "remove",
                            "imageConfig": {"bindTo": "Resources.Images.RemoveIcon"}
                        }
                    ],
                    // Binding to method that initializes subscription to events
                    // of clicking buttons in the active row.
                    "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},
                    // Binding the active record action completion event to handler method.
                    "activeRowAction": {"bindTo": "onActiveRowAction"},
                    // Identifies whether multiple records can be selected.
                    "multiSelect": {"bindTo": "MultiSelect"}
                }
            },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "DataGrid",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                        "rowDataItemMarkerColumnName": "UsrDocument"
                    }
                },
                {
                    // Operation type - merging.
                    "operation": "merge",
                    // Name of the schema element under operation.
                    "name": "AddRecordButton",
                    // The object, whose properties will be combined with the schema element properties.
                    "values": {
                    	"click":{"bindTo":"addRecord"},
                        "visible": {"bindTo": "getToolsVisible"}
                    }
                }
            ]/**SCHEMA_DIFF*/
        };
    }
);

The trick is in the esq.on("createviewmodel", this.createViewModel, this); string in the onDocumentInsert method.

 

Best regards,

Oscar

Oscar Dylan,

 

It works.

Thanks very much!

Show all comments