Message Handler not working in popup


I need help regarding message handler which I am listening in the popup.

Alert Popup Screenshot with Message Handler

I have a table in view called Recipes and there is a popup called alert. What I am doing is when user presses a Reload button present on view Recipes, the popup alert.opens. There are 2 buttons on a popup alert. When user presses button Confirm Overwrite it reads the values of particular column from the table present in view called Recipes. For this I am passing table data as a payload and opening a popup. see snip below

Sending Message Screenshot upon pressing Reload

In 2.Script, I am only opening a popup.

However this seems not working and I am not getting issue. for a trial I also added a label in a popup and listening payload[‘dropdownValue’] in the label.props.text but still no luck.

Please let me know if you need any more screenshots if its not clear and help me on this. Thanks!

You should look at the Gateway logs for errors from your scripts. I’m 99% sure your scripts are failing.

# this should work, assuming the data supplied for 'table' is correct. = payload['table']

# this should NOT be done; this would probably result in a component error.
self = payload['table']

If you’d like to supply the view.json files I could take a look at the scripts to see what is not working. I would also recommend that you supply some logging at the start of each script to verify the script is being invoked:

# change the value of x to be whatever the script is doing.
system.perspective.print('start script x')

What LOOKS to be happening is that the popup is opening, but the table has no data. This is occurring because the two Actions you supplied to be invoked for the click event of the button are executing asynchronously; the sendMessage call is probably being invoked/executed before the popup has been built on the page.

Think of it like this: you are saying “hello” before the Popup has picked up the phone.

You should pass the table data to the project script, which in turn passes that value to the openPopup invocation as the params argument:

def showAlert(x, y, z, payload):
    system.perspective.openPopup(x, y, z, params=payload)

The Popup View should then have a table_data param to receive this info, and the Table should bind against that param value.