Hi Team,

I would like to set an alert based on validations in a Multi-select-lookup detail object.

I have replaced the Account object and added a new field UsrParentComapny which points to the Account object itself.

Now, account is added as a multiselect lookup detail object in a section.  I would like to setup validation based on the selected values in the multiselect lookup.

Validation Required:

if the user selects a company (Account) that is a parent company (UsrParentCompany of Account) then he can’t select the comapnies (Account) that has this UsrParentCompany, 

If he tries to select such company (Account) there will be a pop-up: “you can’t choose more than one daughter company"
 

I have provided a sample Multiselect Lookup of Products. similarly i have Account object as multiselect detail object in another section 

 

 

Kindly guide to achieve the validation.

Regards,

Bhoobalan P.

Like 0

Like

1 comments

Hi Bhoobalan,

 

In the addCallBack function from this instruction (Academy instruction on adding the multiselect lookup) the list of selected rows is formed in this part of code of the method:

 

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

 

You need to debug this method and exclude those accounts from items that don't feat the conditions (it has a parent account selected as an account in your custom section). The check can be performed via a custom esq that refers to accounts and checks if the account is a daughter company or not (you will need to create such a esq query). And in case some of the items in selectedRows is not suitable it will be automatically removed from the selectedRows and the further logic won't be triggered for records that shouldn't be processed. So you will need to create a custom esq that will perform this check.

 

Best regards,

Oscar

Show all comments

I am using this add-on for the multi-select functionality: Multi-select text field setup for Creatio

 

Now I want to filter this multi select field by another lookup on the same page. This works fine when I'm using regular lookups and a business rule.

 

I tried to modify the example in the documentation by changing "Name" to the correct column name in my multi select lookup. Then i changed "Customer" to this.get(UsrLookup2). 

 

When lookup2 is filled in on my page and I then open the multi select one, I get no options to choose from in the selection box.

 

Does anyone know what I should change?

 

"filters": function() {
return Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL,
"Name",
"Customer");
},

 

Like 0

Like

0 comments
Show all comments

Hi Team,

I would like to retain the values/records in the detail when i click on + sign (Add record in the detail) into the modal pop-up of multiselect lookup.

STEP 1: I'm using a multiselect lookup object and selecting couple of values on Add Record of a detail (i.e., clicking + sign)

 

STEP 2 : After selecting values from step 1, when i click + sign again, i would like to retain the values available in the detail grid to the modal popup with the checkbox selected.

 

STEP 3 : The  multiselect lookup's modal pop-up should be like this.

 

when one of the selected value in STEP 1 (ex., incoming document 1) is unchecked and a new value is selected (ex., Regulation 3) the insertion should act accordingly.

Incoming Document 1 --> Should be removed from detail (since its value is unchecked now)
Minutes 2 --> should be available in the detail (since already selected in STEP 1)
Regulation 3 --> Should be added to the detail.

Kindly guide to achieve the above!

Thanks in advance!

Regards,

Bhoobalan P.

 

 

 

Like 0

Like

1 comments

Hi Bhoobalan,

 

Basically there are two tasks that you need to solve:

 

1) Display already added records to the detail in the modal window that is opened upon adding new records to a detail

2) Check these added records in the list

 

As for the 1-st task - you will need to override the openLookupWithMultiSelect method from the LookupMultiAddMixin mixin (for example you can create your own module and copy the code of the original LookupMultiAddMixin mixin and use it in the detail schema). The part of code that checks already records is:

const filtersConfig = this.createAlreadyAddedRecordsFilter();

As for the 2-nd task you will need to dynamically change CSS for elements in the modal window and add grid-row-selected CSS to it. Unfortunately we don't have any practical examples on this particular step.

 

Best regards,

Oscar

Show all comments

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

Hi Team,

 

we can create a detail with selection lookup as described in the article below. 

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

 

I wanted to display a particular column alone with distinct values. How could we achieve it here?

 

Please find the attached image for reference. Thanks in advance.

 

Regards,

Bhoobalan P

 

 

Like 0

Like

3 comments

Do you want to select exact document or document type?

Thanks for the response Vladimir Sokolov,
Here i need to display the document type column alone with distinct values along with multi select (no duplicates).

 

I want to select document type.

 

Hello Bhoobalan,

 

Hope my message finds you well.

 

If I understood your business task correctly, in this example you're trying to operate with 'Document' lookup. For this lookup can exist a lot of duplicated documents that are connected to different companies/accounts. In this situation, if you want to have distinct records and avoid seeing duplicated records in the list, you are able to merge the lookup values.

 

In order to do that, you just need to go to the section Lookups (in System Designer functional area), then find the lookup ‘Document’. After that click on the button ‘Actions’ and select ‘Select multiple records’. Then select the values you want to merge and select the option ‘Merge records’. After that, you will be able to choose the record you want to be kept. As a result, all duplicate records will be merged and there will be only distinct records.

 

More about Merging operation you can find in the following article:

https://academy.creatio.com/documents/base/7-16/how-duplicates-are-merg…

 

Best regards,

Roman

Show all comments