Question

Message Arguments is undefined on Load

Hi,

 

I have an issue on getting the message argument from subscribe that the argument is undefined. I want to get the message from page on initialize if status is "On Processing" so I can able to hide or lock columns to a details on load.

 

Here is the publish from the Page:

				esq.getEntity(recordId, function(result) {
					if (!result.success) {
						// For example, error processing/logging.
						this.showInformationDialog("Data query error");
						return;
					}
					var status = result.entity.get("Status");
 
					if(status.displayValue === "Order Processing"){
						this.set("ButtonVisible", false);
					}
					debugger;
					if(status.displayValue !== "Draft"){
						this.sandbox.publish("CheckOrderDraft", {IsDraft: false}, []);
					}else{
						this.sandbox.publish("CheckOrderDraft", {IsDraft: true}, []);
					}
 
				}, this);



Here is the subscribe on Detail:

 

			init: function(){
				this.callParent(arguments);
				debugger;
				this.sandbox.registerMessages(this.messages);
				this.processMessages();
 
			},
			processMessages: function(){
				debugger;
				this.sandbox.subscribe("CheckOrderDraft", this.onCheckOrderDraft(), this, []);
			},
			onCheckOrderDraft: function(arg){
				if(!arg){
					debugger;
					this.set("canDistributorEdit", false);
				}
			}



 

Like 0

Like

3 comments

Hi,

 

The issue can be that esq is asynchronous and the message is passed when the subscribe to message is not initialized. Or the message itself is not initialized on the detail. You need to debug the code execution and see the exact place when the message is formed and then passed to the detail subscribe and handler and analyze the call stack and chain of executions to see where the issue comes from.

Your right Oleg. The ESQ was executed first before the message was initialized on the Detail module. Do you have a suggestion on how I can able to get Status from a Page to the Detail on load? 

 

Joseph Francisco,

 

I could advice either using the Terrasoft.chain construction (find examples in the sources in the code on the UI) to execute functions one by one once the page is initialized or call this method not on the page load, but once the page is loaded (like button click). 

Show all comments