Figma Support Forum

In set_fillStyleId:


WechatIMG17

I could run the script to override the FillStyleId in my own document; however, When I switched files to run the script Error thrown with ‘in set_fillStyleId: Cannot set style successfully: Cannot find style’.How do I fix the error?

Where is the style b coming from? If it’s not local and is published to the library, you need to import the style first using figma. importStyleByKeyAsync(key: string). Docs: figma · Figma Developers

1 Like


Thank you for your reply, I use this method to print the FillStyleId;so where are the key get from?

figma. importStyleByKeyAsync(key: string)

You need to get style by id and then get the style key from the resulting paint style.

1 Like

Do I need to import all the remote styles or just import one which other styles in the same library with will be read?It does not seem necessary to import all of them and the scripts works!

You only need to import the styles which you want to set on nodes. If you don’t need to set a certain style to node, you don’t need to import it.

1 Like

kilikae|video
Ok i get it
!, I’m just curious about that the remote styles I haven’t imported yet but I can still rewrite them with ‘fillStyleId’.