Paste Script not working. Why?

I've been fighting this for some time.
I have a Named Clipboard which I transfer to the System Clipboard so I can paste from within an external Javascript Function called from the macro. To simplify the test I've included only the "paste" script line (but the same error occurs).

The "SC_Prep" clipboard contains an svg vector file. Even though the named clipboard is loaded into the System Clipboard at the beginning and is verified to contain a text string (SampleCrop), the script pastes whatever was in the clipboard before the macro was run.

I've tried loading the System Clipboard in a previous macro but still, when the script runs it pastes what was in the SC before it was reloaded.

BUT, if the script is run a second time the "SC_Prep" clipboard elements are pasted properly. The script continues to work as long as the System Clipboard is not disturbed.

A "workaround" is to paste directly from the Named Clipboard (see disabled group), but this is much slower than pasting from the script.

Does anyone have an idea what is wrong with my approach to this macro/script?

Paste Clipboard test.kmmacros (7.8 KB)

My solution was to add this script to test the result of pasting. If the pasted artwork is not correct it is deleted and the "Paste" script run again. The second paste is always correct.

I would still like to understand why updating the System Clipboard at the beginning of the macro is not enough.

Paste Sample Crop.kmmacros (4.8 KB)