Skip to main content
Question

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


Ondrej_Pesicka

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?

This topic has been closed for comments

4 replies

tank666
  • 4863 replies
  • January 9, 2024

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


Ondrej_Pesicka

That was what I was missing. I was searching by get.. not import.. 🤦‍♂️ Thanks


Jose_Luis_Gonzalez_Jimenez

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.


tank666
  • 4863 replies
  • February 20, 2024

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

figma.com

https://www.figma.com/developers/api#variables-endpoints


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings