Skip to main content
Sergey_Dubina
New Member
December 12, 2024
Question

importVariableByKeyAsync returning local variable

  • December 12, 2024
  • 4 replies
  • 74 views

I’m trying to use importVariableByKeyAsync method: importVariableByKeyAsync | Plugin API.

It’s described as method for getting variable from published library. But I’m getting only local variable

This topic has been closed for replies.

4 replies

tank666
December 12, 2024

Could you please add a detailed description? This method imports a remote variable from a library.

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
Sergey_Dubina
New Member
December 13, 2024

My goal is to compare local and published variables. Is there any other way to do this if method importVariableByKeyAsync doesn’t match my needs?

Sergey_Dubina
New Member
December 13, 2024

I published my variable to library. Then I changed the same variable locally. When I’m calling importVariableByKeyAsync, I expect to get variable stored in published library, but I get local variable

tank666
December 16, 2024

It looks like you are running the plugin and using this method in the same file where this variable is published. Instead, you should have run the plugin in a different file (not the library file where this variable is published). That is, get a local variable in a library file, then open another file and import that variable.

Also consider using REST API if your plan allows it:
https://www.figma.com/developers/api#variables

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