#How would I expose a utility function in the global context for the client editor?

1 messages · Page 1 of 1 (latest)

covert fox
#

Hello,

I want to provide a function that can be accessed from any input widget through the widget properties panel. I would like the function to appear in the context list of available functions/objects accessed through mustache syntax (see screenshot A)

I was able to expose a function as an action in this list, but it cannot be invoked (see screenshot B)

I am using version 0.1.0 (taken from appsmith/app/client/package.json), can someone please advise?

Note: I am aware of JSObjects but do not want to create one. This function needs to be available for all end-users of the appsmith framework we provide. I also do not want to expose the function through the JSObject tab for modification.

flat elkBOT
#

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:

  1. 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!";
}
}

  1. 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() }?} **.

  2. 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.

covert fox
#

thank you for that. I should have mentioned that I do not want to create a JSObject because this function needs to be available for all end-users of the appsmith framework we provide. I also do not want to expose the function through the JSObject tab for modification.

flat elkBOT
#

I'm not sure of the answer to your question. Could you rephrase it or would you like to speak to a human agent?

#

I'm not sure of the answer to your question. Could you rephrase it or would you like to speak to a human agent?

#

I'm not sure of the answer to your question. Could you rephrase it or would you like to speak to a human agent?

#

I'm not sure of the answer to your question. Could you rephrase it or would you like to speak to a human agent?

covert fox
#

I would like to speak to a human agent please

flat elkBOT
#

Someone from our team will reach out to you on this thread. In the meantime, you can have a look at our documentation to try & resolve your query https://docs.appsmith.com?utm=bot

Organizations build internal applications such as dashboards, database GUIs, admin panels, approval apps, customer support tools, etc. to help improve their business operations. Appsmith is an open-source developer tool that enables the rapid development of these applications. You can drag and drop pre-built widgets to build UI. Connect securely...