What happens when you import a component (say, a symbol) from a library into your document is, Sketch actually creates a copy of that symbol and assigns it a brand new symbolID
(they have to be different because this copy of the symbol in your document won't always be the same as its library counterpart – say, the latter may have been updated in the library, but those changes are not yet synced by the user into the document).
Now, it seems that you're trying to query this local copy of a symbol using its symbolID
from the component library (a so called "remote ID" or "foreign ID") – which, again, won't work since the symbolID is different now.
Unfortunately, there's no way to query symbol masters by their remote IDs in the JS API. We have to fall back to native/unsafe API a bit for this:
let remoteID = ... // this is a symbolID you're using now (and which doesn't work with getSymbolMasterWithID)
const sketch = require('sketch')
const util = require('util')
let document = sketch.Document.getSelectedDocument()
let nativeDocument = document.sketchObject.documentData()
let allSymbols = util.toArray(nativeDocument.allSymbols())
// This will be a local symbol in your document. You may confirm that result.symbolId != remoteID
let result = sketch.fromNative(allSymbols.find(s => {
if (!s.foreignObject()) {
return false
}
return s.foreignObject().originalMaster().symbolID().isEqualToString(remoteID)
}))