I am trying to get the Id(s) from a detail grid
define("UsrManifests1Page", ["ProcessModuleUtilities","ConfigurationGrid", "ConfigurationGridGenerator", "ConfigurationGridUtilities"], function(ProcessModuleUtilities) { return { entitySchemaName: "UsrManifests", messages: { "SetNewQuoteButtonVisibility": { mode: this.Terrasoft.MessageMode.PTP, direction: this.Terrasoft.MessageDirectionType.PUBLISH }, "RowSelectedInStopDetail": { mode: Terrasoft.MessageMode.PTP, direction: Terrasoft.MessageDirectionType.PUBLISH } }, attributes: {}, modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/, details: /**SCHEMA_DETAILS*/{ "Files": { "schemaName": "FileDetailV2", "entitySchemaName": "UsrManifestsFile", "filter": { "masterColumn": "Id", "detailColumn": "UsrManifests" } }, "UsrSchema96dcd22dDetail16ad79d8": { "schemaName": "UsrSchema96dcd22dDetail", "entitySchemaName": "UsrPassengers", "filter": { "detailColumn": "UsrUsrManifests", "masterColumn": "Id" } }, "UsrStops": { "schemaName": "UsrSchema00abbfacDetail", "entitySchemaName": "UsrManifestStops", "filter": { "detailColumn": "UsrManifest", "masterColumn": "Id" } } }/**SCHEMA_DETAILS*/, businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/, methods: { onNewQuoteClick: function() { console.log("************************BEGIN*******************************"); var selectedRow = this.get("GridData").get(activeRow); console.log(this.get("GridData").get(activeRow)); console.log(selectedRow.get("UsrStopNumber")); console.log("multiSelect"); console.log(this.get("multiSelect")); console.log("ActiveRow"); console.log(this.get("ActiveRow")); var testVar="HelloGoodbye"; if (!this.get('multiSelect')){ console.log("Multiselect false"); testVar="false"; } else{ console.log("Multiselect true"); testVar="true"; } this.showInformationDialog(testVar); var currentRecordId = this.get('ActiveRow'); if (this.get('multiSelect')) { var selectedRecords = this.get('SelectedRows'); currentRecordId = JSON.stringify(selectedRecords); } var args = { sysProcessName: "UsrProcess_60a5043", parameters: { UsrStopList: currentRecordId } }; ProcessModuleUtilities.executeProcess(args); console.log("************************END*******************************"); }, onNewQuoteClick2: function() { const isMultiSelect = this.get("MultiSelect"); console.log("isMultiSelect"+isMultiSelect); this.showInformationDialog(isMultiSelect); var currentRecordId = this.get("ActiveRow"); if (isMultiSelect) { var selectedRecords = this.get("SelectedRows"); currentRecordId = JSON.stringify(selectedRecords); } var args = { sysProcessName: "UsrProcess_60a5043", parameters: { UsrStopList: currentRecordId } }; ProcessModuleUtilities.executeProcess(args); }, getNewQuoteButtonVisible: function() { this.sandbox.publish("SetNewQuoteButtonVisibility", true, [this.sandbox.id]); //return result; return true; }, rowSelected: function() { this.sandbox.publish("RowSelectedInStopDetail", { test: "TEST!!" }, [this.sandbox.id]); console.log("rowSelected successfully triggered"); }, getSelected: function() { this.sandbox.subscribe("RowSelectedInStopDetail", function(arg) { //console.log("test " + arg.test); }, this, [this.sandbox.id]); //[this.getSenderSandboxId()]); } }, dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/, mixins: { ConfigurationGridUtilites: "Terrasoft.ConfigurationGridUtilities" }, diff: /**SCHEMA_DIFF*/[ { "operation": "insert", "name": "NewQuoteButton", "values": { "itemType": 5, "style": "default", "caption": { "bindTo": "Resources.Strings.UsrManifestsSendEmailButton" }, "click": { "bindTo": "onNewQuoteClick" }, "visible": { "bindTo": "getNewQuoteButtonVisible" }, "classes": { "textClass": [ "actions-button-margin-right" ] } }, "parentName": "LeftContainer", "propertyName": "items", "index": 9 }, { "operation": "insert", "name": "UsrName33f1eec2-6c43-46f3-9263-464b14c8828f", "values": { "layout": { "colSpan": 24, "rowSpan": 1, "column": 0, "row": 0, "layoutName": "ProfileContainer" }, "bindTo": "UsrName", "enabled": false }, "parentName": "ProfileContainer", "propertyName": "items", "index": 0 }, { "operation": "insert", "name": "STRING1e5e9a01-15e6-4cdb-b8c0-e471faa21806", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 0, "row": 0, "layoutName": "Header" }, "bindTo": "UsrJourneyFrom", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 0 }, { "operation": "insert", "name": "STRING3f76c609-798b-45fc-ab07-387903e4d109", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 12, "row": 0, "layoutName": "Header" }, "bindTo": "UsrJourneyFromID", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 1 }, { "operation": "insert", "name": "STRINGf13e72c4-6d88-43f1-b201-88ec1b9b0a1d", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 0, "row": 1, "layoutName": "Header" }, "bindTo": "UsrJourneyTo", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 2 }, { "operation": "insert", "name": "STRINGe6c410d2-67e0-4e24-a2fb-03238c8e76c6", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 12, "row": 1, "layoutName": "Header" }, "bindTo": "UsrJourneyToID", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 3 }, { "operation": "insert", "name": "STRING208798a0-00d8-49bb-ae19-786b0893ecb9", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 0, "row": 2, "layoutName": "Header" }, "bindTo": "UsrRoute", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 4 }, { "operation": "insert", "name": "STRING09f1c6bf-70bf-4da7-a081-28cb7ef76469", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 12, "row": 2, "layoutName": "Header" }, "bindTo": "UsrRouteID", "enabled": false }, "parentName": "Header", "propertyName": "items", "index": 5 }, { "operation": "insert", "name": "DATETIME61cb3508-b058-41ec-9706-b8a85d5f9b11", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 0, "row": 3, "layoutName": "Header" }, "bindTo": "UsrDeparture", "enabled": true }, "parentName": "Header", "propertyName": "items", "index": 6 }, { "operation": "insert", "name": "DATETIMEcba61966-987c-4f8c-8600-d012a8f3e424", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 12, "row": 3, "layoutName": "Header" }, "bindTo": "UsrArrival", "enabled": true }, "parentName": "Header", "propertyName": "items", "index": 7 }, { "operation": "insert", "name": "LOOKUP23f48f49-3db0-4d6a-a296-71d3f6c51c33", "values": { "layout": { "colSpan": 12, "rowSpan": 1, "column": 0, "row": 4, "layoutName": "Header" }, "bindTo": "UsrBusBrand", "enabled": true, "contentType": 3 }, "parentName": "Header", "propertyName": "items", "index": 8 }, { "operation": "insert", "name": "Tab8ea35db5TabLabel", "values": { "caption": { "bindTo": "Resources.Strings.Tab8ea35db5TabLabelTabCaption" }, "items": [], "order": 0 }, "parentName": "Tabs", "propertyName": "tabs", "index": 0 }, { "operation": "insert", "name": "UsrStops", "values": { "itemType": 2, "markerValue": "added-detail", "selectRow": {"bindTo": "rowSelected"} }, "parentName": "Tab8ea35db5TabLabel", "propertyName": "items", "index": 0 }, { "operation": "remove", "name": "ESNTab" }, { "operation": "remove", "name": "ESNFeedContainer" }, { "operation": "remove", "name": "ESNFeed" }, { "operation": "remove", "name": "ChangesHistoryTab" }, { "operation": "remove", "name": "SmrLoggingRecordDetailV2" } ]/**SCHEMA_DIFF*/ }; });
to pass to a process through a button on the Edit page. No matter what I try, the value is undefined. Can anyone point me to where I am going wrong here?
The attempts are all in the onNewQuoteClick section.
Thanks
Like
Hello Heather,
Can you please specify what schema "UsrManifests1Page" represents?
By clicking "Send Email" you need to read the active row on the "Stops" detail, is it correct?
Dmytro Vovchenko,
The screenshot is the Edit page of the Manifests (UsrManifests) schema (UsrManifests1Page). The Manifests schema includes a detail grid for the Stops schema. I need to send one or multiple IDs from the Stops detail to the button so I can pass that to a process.
Thanks very much
Heather,
The process of getting information about detail is quite tricky, but it's not impossible. To do it you need to use sandbox messages.
In the Stops detail schema you need to define a message and publish it on some event, for example in the onActiveRowChange method:
messages: { "Message1": { mode: this.Terrasoft.MessageMode.PTP, direction: this.Terrasoft.MessageDirectionType.PUBLISH } }, ---- methods: { onActiveRowChange: function(buttonTag, primaryColumnValue) { this.callParent(arguments); this.sandbox.publish("Message1", this.getActiveRow().values.Id, ["Message1"]); },
The purpose of this message is to send the detail active row id.
Then on the UsrManifests1Page schema, you need to subscribe for this message and proceed it:
messages: { "Message1": { mode: this.Terrasoft.MessageMode.PTP, direction: this.Terrasoft.MessageDirectionType.SUBSCRIBE } ------ attributes: { "ActiveId": { dataValueType: Terrasoft.DataValueType.GUID, type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN } ------ methods: { init: function(){ this.callParent(arguments); this.sandbox.subscribe("Message1", this.onMessageSubscribe,this, ["Message1"]); }, onMessageSubscribe: function(args) { this.set("ActiveId", args); }, onButtonClick: function() { console.log(this.get("ActiveId")); }
In this example, we store the active row id in the ActiveId attribute.
After it's done we can access its value as we want.
Dmytro Vovchenko,
Thank you, I sort of got this working in a rudimentary way. But I think I will need to expand it with related methods for when a row is unselected. Is there a list somewhere of all the methods like
onActiveRowChange so I can see what my options are for methods? I didn't find anything in the academy.
Thanks very much.
Dmytro Vovchenko,
I got this working using the rowSelected function, however, it is always missing the last item selected. Are you aware of a function that will also include the last one selected? I have tried ActiveRow, rowSelected, SelectedRows. Not sure where that one would be stored.