Implementing messages via sandbox for details

Question

Where can I find information on implementing messages between details via sandbox? 

Answer

Examples of implementing massage exchange between details via sandbox:

1) AccountBillingInfoDetailV2:

define("AccountBillingInfoDetailV2", [], function() {
	return {
		entitySchemaName: "AccountBillingInfo",
		details: /**SCHEMA_DETAILS*/{
		}/**SCHEMA_DETAILS*/,
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "DataGrid",
				"values": {
					"selectRow": {
						"bindTo": "rowSelected"
					}
				}
			}
		]/**SCHEMA_DIFF*/,
		methods: {
			rowSelected: function() {
				this.sandbox.publish("RowSelectedInFirstDetail", { test: "param anything" }, [this.sandbox.id]);
				console.log("rowSelected in first detail...");
			}
		},
		messages: {
			"RowSelectedInFirstDetail": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			}
		}
	};
});

2) AccountAddressDetailV2:

define("AccountAddressDetailV2", [], function() {
	return {
		entitySchemaName: "AccountAddress",
		details: /**SCHEMA_DETAILS*/{
		}/**SCHEMA_DETAILS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
		methods: {
			init: function() {
				this.sandbox.subscribe("RowSelectedInFirstDetail", function(arg) {
					console.log("test " + arg.test);
				}, this, [this.getSenderSandboxId()]);
			},
			getSenderSandboxId: function() {
				return this.sandbox.id.replace("_AccountAddress", "_AccountBillingInfo");
			}
		},
		messages: {
			"RowSelectedInFirstDetail": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			}
		}
	};
});

 

Like 0

Like

Share

2 comments

I have an error coming from the arg value:

Unhandled Promise rejection: arg is not defined ; Zone: <root> ; Task: Promise.then ; Value: ReferenceError: arg is not defined

 

Where is that coming from? Why do I get it?

Hello Maria,

 

Could you please provide us the full code that you have implemented? Also, as long as I understand this error is being shown in the console. Does it point exactly to this line 

console.log("test " + arg.test); 

?

And what are the steps that you follow to reproduce this problem and receive this error?

 

Best regards,

Dariy

Show all comments