getVariableById doesn't work if the variable is not in the file

Hi, I have a plugin that uses a list of hardcoded variable IDs to set colors for text.

When I create a new file, link the library with my variables, and call getVariableById it doesn’t fail but when I try to apply it to a node using setBoundVariableForPaint I get The variable with id "VariableID:7451bd8375ccbe6a2d7e9fcda9e5fcad24dbb1da/1813:605" does not exist at...

When I manually apply the variable to a rectangle in the same file, it then works. So I would say this is a bug. Or maybe I’m missing some other function that I need to use?

Could you describe in detail the steps to reproduce the bug? Are you importing variables using importVariableByKeyAsync method?

1 Like

That was what I was missing. I was searching by get.. not import.. :man_facepalming: Thanks

And how did you get the variable key @tank666 ? I’m facing similar problem, I was using getVariableById and it was easy to get the Id using this Inspector Figma plugin due to I’m using manually created styles in Figma in a external team library I can’t get the variable key with approach.

1 Like

Get a Variable object using a Plugin API or REST API and check the key property.

1 Like