Question

getSelected is not defined trying to work with Sandbox

I am trying to implement a button that will pass the IDs of the items selected in a detail list to a business process. I am trying to use the sandbox to pass the IDs from the detail to the button but I cannot get this to work.

 

I want to be able to select one or many items from the Stops list, then click SEND EMAIL and the IDs from Stops will be passed to the button. Currently when I click the button, it says getSelected is not defined. Any help would be greatly appreciated.

define("UsrManifests1Page", ["ProcessModuleUtilities"], function(ProcessModuleUtilities) {
 
				/*var config = {
						 sysProcessName: "UsrResetEmailCache",
    						parameters: { 
        					SomeProcessParam: "heatherl@corp.pwt.ca"
					 		}
						};
						ProcessModuleUtilities.executeProcess(config);*/
 
	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() {
                //TODO: implement your logic here
				//var selectedIds = this.getSelectedItems();
					var selectedIds=getSelected();
                	this.showInformationDialog("Heather");
            	},
 
            	getNewQuoteButtonVisible: function() {
                /*var newMode = this.isNewMode();
                var result = !newMode; //TODO: implement your logic for visibility here
                */
                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*/,
		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*/
	};
});

 

Like 0

Like

8 comments

You need to use the following approach:

startCustomProcess: function() {
				const isMultiSelect = this.get("MultiSelect");
				var currentRecordId = this.get("ActiveRow");
				if (isMultiSelect) {
					var selectedRecords = this.get("SelectedRows");
					currentRecordId = JSON.stringify(selectedRecords);
				}
				var args = {
                    sysProcessName: "Process_8b81aa5",
                    parameters: {
                        StringPassed: currentRecordId
                    }
                };
                ProcessModuleUtilities.executeProcess(args);
			},

where startCustomProcess is the button click handler for the button that should start a process (or you can additionally develop another way of calling the method if needed). As a result what happens:

 

1) isMultiSelect parameter will check if multiselect is currently enabled and pass all the selected rows to a process

2) if isMultiSelect is false then the active selected record will be passed to a process

3) If multiple records are going to be passed to a process then they should be stored as a JSON string (this.get("SelectedRows") returns an array of Ids as strings)

4) StringPassed is the string parameter of the Process_8b81aa5 business process.

 

And it's left to parse this JSON string using C# in a script task and process all the records.

 

Best regards,

Oscar

Thanks Oscar, this seems to work well. Are you able to tell me how I actually get the Json into a String properly so I can inspect the results?

 

This is what I'm doing in my process but I don't think I've found the correct format so far.

string jsonString = JsonSerializer.Serialize("UsrStopList");
 
 
Set("ProcessSchemaParameter1", jsonString);
 
return true;

 

Oscar Dylan,

I did not properly reply to you directly. Please see my response above if you have a chance. Thanks.

Heather,

 

You need to try the method similar to the one proposed here. This will create a JSON string that then can be processed.

Oscar Dylan,

I'm not sure what I'm missing here but it doesn't seem to be getting the value of MultiSelect to begin with. I am getting the error: 

TypeError: Cannot read properties of undefined

 

I have tried it as const as you suggested but got a warning that const is not available, so I tried as a var. I tried double and single quotes around MultiSelect as I found examples of both in the academy.

onNewQuoteClick: function() {/*
                //TODO: implement your logic here
				//var selectedIds = this.getSelectedItems();
					var selectedIds=getSelected();
                	this.showInformationDialog("Heather");*/
					var isMultiSelect = this.get('MultiSelect');
					this.showInformationDialog("multiselect: "+ isMultiSelect.ToString());
					var currentRecordId = this.get('ActiveRow');
 
					this.showInformationDialog("isMultiSelect before");
					this.showInformationDialog(currentRecordId.ToString());
 
					if (isMultiSelect) {
						var selectedRecords = this.get('SelectedRows');
						currentRecordId = JSON.stringify(selectedRecords);
						this.showInformationDialog("isMultiSelect True");
					}
					var args = {
                    	sysProcessName: "UsrProcess_60a5043",
                    	parameters: {
                        	UsrStopList: currentRecordId
                    	}
                	};
                	ProcessModuleUtilities.executeProcess(args);
            	},

 

I even tried this and the code bypassed the if/else statement and went straight to the dialog box at the end "isMultiSelect before".

					if (!this.get('multiSelect')){
                			this.showInformationDialog("Multiselect false");
            			}
					else{
						this.showInformationDialog("Multiselect true");
					}
					//this.showInformationDialog("multiselect: "+ isMultiSelect);
					var currentRecordId = this.get('ActiveRow');
 
					this.showInformationDialog("isMultiSelect before");

 

It seems like it will only allow you to have one dialog box, otherwise they are ignored. So that explains my last issue. But it seems to me that the value of currentRecordId is not getting set (it is blank), and isMultiSelect is resolving to False no matter how many records I select, so I'm not sure what I am missing here.

Show all comments