Skip to content
Back

access my custom variable inside my function code

  • 0
  • Functions
showmore
4 Apr, 2023, 07:44

I create Functions using dart and Inside my functions setting tab, I add custom variables ->updateVariable->Create Variable key : my_key, value: "test123" the question how can I access my custom variable inside my dart function code ? I tried this final myKey = my_key; can you show how can I do it, thanks

TL;DR
User is asking how to access a custom variable inside their Dart function code. They have already tried `final myKey = my_key;` but it didn't work. Solution: To access custom variables in Dart function code, use `req.variables['my_key']` where `my_key` is the key of the custom variable.
joeyouss
4 Apr, 2023, 09:22

Hi 👋

whataboutno13
4 Apr, 2023, 09:51

Should be possible the same way it is done for the other variables as well: final myKey = req.variables['my_key'];

whataboutno13
4 Apr, 2023, 09:53

From the docs: https://appwrite.io/docs/functions#writingYourOwnFunction

TypeScript
final secretKey =
    req.variables['SECRET_KEY'] ??
    'SECRET_KEY variable not found. You can set it in Function settings.';
showmore
4 Apr, 2023, 10:26

ho thanks Jyoti 😀

whataboutno13
4 Apr, 2023, 11:28

No problem <:appwritecheers:892495536823861258>

whataboutno13
4 Apr, 2023, 11:29

@showmore Do not forget to mark your post with "[SOLVED]" if it was solved

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more