Skip to main content
Question

Plugin unable to access figma.teamLibrary despite manifest with "permissions": ["teamlibrary"]


George15

Per the documentation, plugins should be able to access the new figma.teamLibrary object when the manifest is configured with “permissions”: [“teamlibrary”].

I’ve got a Figma with a team library which is visible from the developer console window:

> figma.teamLibrary
> {getAvailableLibraryVariableCollectionsAsync: ƒ, getVariablesInLibraryCollectionAsync: ƒ}

However, when I try to access this object from a plugin in development which has the permissions configured in the manifest then

figma.teamLibrary returns as *undefined*

From the plugin I can log the figma object to the console and see that, in fact “teamLibrary” is missing.

Anyone had success accessing teamLibrary from a plugin yet?

This topic has been closed for replies.

4 replies

tank666
  • 4873 replies
  • June 30, 2023

I just tested this on my side and both the property and its methods work as expected.


George15
  • Author
  • 2 replies
  • June 30, 2023

@tank666 Thanks for the response, can you please confirm some details for me?

Here’s my setup:
1) Figma project - Library Source

  • this project contains a single variable collection: “Collection 1” and a single color variable “test” set to #ffffff (not that the color matters).
  • I published this as a library to one of my enterprise subscription teams, including “test” variable as an export

2) Figma project - Library Test

  • I imported “Library Source” project as an asset library, create a rectangle node and assign the fill property to the “test” variable from “Library Source”

Next I created a basic, run-once plugin with the following manifest:

{
  "name": "library-variables",
  "id": "1256735375235080757",
  "api": "1.0.0",
  "main": "code.js",
  "capabilities": [],
  "enableProposedApi": false,
  "permissions": ["teamlibrary"],
  "editorType": [
    "figma"
  ],
  "networkAccess": {
    "allowedDomains": [
      "none"
    ]
  }
}

And this in the code.js file:

console.clear();
console.log(figma.teamLibrary);

figma.closePlugin();

Running the plugin, the console output remains: undefined and I cannot access teamLibrary from within the plugin.

If I run this in the console window directly: console.log(figma.teamLibrary) then I get this result:

{getAvailableLibraryVariableCollectionsAsync: ƒ, getVariablesInLibraryCollectionAsync: ƒ}

Not sure why the plugin isn’t returning the same object reference.


tank666
  • 4873 replies
  • July 1, 2023

So the difference between your manifest file and mine is that I had the proposed API enabled.


George15
  • Author
  • 2 replies
  • July 2, 2023

Thank you, @tank666 , that was the trick.


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