Skip to main content
Sergey_Dubina
New Member
Dec 12, 2024 6:51 PM UTC
Question

importVariableByKeyAsync returning local variable

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
Dec 12, 2024 8:14 PM UTC

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
Dec 13, 2024 3:52 PM UTC

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
Dec 13, 2024 3:53 PM UTC

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
Dec 16, 2024 10:21 AM UTC

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