How to set color styles to a variable collection in another file?

I’m programmatically updating color styles to point to variables. This works great when the variable collection is in the current file and I can use getLocalVariableCollections. However, for my use case the variable collection I want to use lives in a separate library file from the file I’m trying to update with variables. I’ve tried using getVariableCollectionById by using the ID of the variable collection in the other file, but my console logs “The variable collection with id “<ID>” does not exist” - I’m assuming it’s only checking the current file for a collection with this ID, which is why it’s saying not found.

You can manually set color styles in the UI to variables from another library, so how can I do this via the plugin API?

To use variables from a library, you need to import it first. Please read the documentation: