Skip to main content
Ondrej_Pesicka
Jan 9, 2024 8:35 AM UTC
Question

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?

This topic has been closed for replies.

4 replies

tank666
Jan 9, 2024 11:03 AM UTC

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

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Ondrej_Pesicka
Jan 9, 2024 2:09 PM UTC

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

Jose_Luis_Gonzalez_Jimenez
New Member
Feb 20, 2024 5:09 PM UTC

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
Feb 20, 2024 10:14 PM UTC

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

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank