appsmith: [Bug]-[5196]:JSObject Async function response data is not set when the function is executed using widget event like button onClick

Is there an existing issue for this?

  • I have searched the existing issues

Description

If you bind the data from a JSObject to a widget using {{JSObjectName.FuncName.data}} and then execute the function on click of button, it doesn’t update or display the data on the widget. The evaluated value in widget and console logs show that the function was executed but the widget does not display any data.

Discord users query - https://discord.com/channels/725602949748752515/760761686549463060/994148281355612240

For a JSObject function where run on page load is turned off

Steps To Reproduce

  1. bind the data from a JSObject to a widget using {{JSObjectName.FuncName.data}}
  2. execute the function on click of button
  3. check the data not being reflected in the widget

Public Sample App

No response

Version

1.7.6

Front logo Front conversations

Possible solution

myFunc : (function(){ const result = (functionCode)();$$setResponseData("JSObject.myFunc", result) })

here, $$setResponseData is an internal method to set value in dataTree and is used above to set the response of JSObject function run to the response data path.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@felix-appsmith this will be available in release in 2 weeks.

met the same issue, hope to have a fix soon.

Update: It turns out this is a slightly complicated bug to fix. We have a couple of ideas on the table but we need more time to come up with the right solution. We’ll have more updates on this next week.

I fully understand. It’s nice to hear that it’s still being worked on. Keep up the good work!

Update: It turns out this is a slightly complicated bug to fix. We have a couple of ideas on the table but we need more time to come up with the right solution. We’ll have more updates on this next week.

@bharath31 Can you confirm that this is still being worked on?

Update: We’ve picked this issue up in the current sprint. We should have a fix out soon.

Another user reported this issue on our forum.

This bug IMO needs to be a high priority. It cripples the ability to update the widget when the underlying parameters of the API/Query is modified through user interaction. As a workaround, I have utilized (per appsmith’s recommendation too) localStorage , that is storeValue(key, result) then bind the widget with {{appsmith.store.key}}. It works, until it does not as this solution does not scale. Today I blew out my local storage size limit and need to re-think how I am going to keep adding dynamic widgets. By dynamic I mean a widget that needs to be updated as user interacts with the UI. Otherwise widgets populated only once works with JSObjectName.FuncName.data but that is hardly the case for most of the time.

Wrong Bharat @Rishabh-Rathod 😀

Sorry, my bad. 🙈