Issue with finding variables by name in the Designer API

Hey All, I’m working on building an internal app and am having an issue with the designer API, specifically the getVariableByName() method.

I recorded a loom video to explain the issue in more detail and show a demo in more detail (see below), but to explain it briefly the getVariableByName() method is returning null when I include a “/” in the variable name which is super common when setting up large collections of variables. This makes it extremely difficult to create reference variables since getting variables by their ID is a lot less convenient when trying to programmatically create a bunch of variables.

Any help would be appreciated

Hey @Caleb-Raney !

This is expected as the “/” will be removed from the name once created.

Adding “/” will create the variable in the group with the name before the /. Which it sounds like you’re trying to do anyway.

Could you include a sample of the code your running and the variables? also if you are using the v1 or v2 Designer API?

Hey @jonohale Interesting, I didn’t realize the variable names wouldn’t include the folder names. Couldn’t this potentially create issues where there are two variables with the same name in different folders (eg h1/font-size and h2/font-size)?

Here is the github repo of the app I have so far.
Here is the specific file with in use.
I’m using the v2 version of the API

I’m still having issues with the getVariableByName() and am getting inconsistent results, at the moment I was trying to have a workaround where I created variables with a “|” instead of slashes and then just renamed all variables replacing those characters afterwards.

Would love any help with what I might be doing wrong in the createVariable() function. It isn’t working as expected and I’m having a hard time understanding what I’m doing wrong or if its actually a bug.

Hey @Caleb-Raney, applogies for the delay here!

I’ve just done a test with your code (added a / to the test names) and it looks like it is working as expected on my end, even though it does give an error.

I’m getting the / in the name with the V2 Designer API as well, so it may have been resolved on our end.

I’m doing a bit more digging here, as there is still something odd going on at times.