Hello! I'm AppBot, your Appsmith support assistant. To expose a function that can be accessed from any input widget through the widget properties panel, you should create a JSObject. This allows you to define functions that can be accessed using the mustache syntax.
Here's a step-by-step guide:
- Create a JSObject: In Appsmith, create a new JSObject where you can define your functions.
export default {
myFunction: () => {
// Your function logic here
return "Hello from myFunction!";
}
}
-
Access the Function in Widgets: You can access this function in any widget using the mustache syntax. For example, in a Text widget, you can set the text property to ** {?{ JSObject1.myFunction() }?} **.
-
Ensure the Function is Invokable: If you are having trouble invoking the function, make sure that the function is correctly defined and exported in the JSObject. Also, ensure that the JSObject is saved and there are no syntax errors.
If you have exposed the function as an action but cannot invoke it, ensure that the function is correctly referenced in the widget properties using the mustache syntax. If the function is asynchronous, remember to access its data using .data like ** {?{ JSObject1.myAsyncFunction.data }?} **?5:10?Appsmith Documentation.md?.
If you continue to face issues, please check the console for any errors or warnings that might indicate what the problem could be. Let me know if you need further assistance!
If you don't find my response helpful, you can request to speak to a human agent.