InDesign - Placing items from Library

Indesign 2023 on OS Ventura

I am having problems figuring out the terminology to place an item from my indesign library onto a specific page in my document. It appears that the way I am trying to call out the library item is not being understood.

the library is named “zLibrary.indl”
the item in the library panel is called “Compuweigh”

if (pageWidth = 12.0) and (pageHeight = 17.63) then
tell document 1
tell spread 1
set allow page shuffle to false
make page at after page 1
end tell
tell application “Adobe InDesign 2023”
– Set the target document and library names
set targetLibName to “zLibrary.indl”
– Get a reference to the target document and library
set targetLib to library targetLibName
– Get a reference to the item you want to copy
set targetItem to item 1 of (every item of targetLib whose name is “Compuweigh”)
– Get a reference to the target page of the target document
set targetPage to page 2 of active document
– Copy the item to the target page
duplicate targetItem to targetPage
end tell
end tell
end if

I am at a loss as t what is wrong.
David

First, the library has to be open in InDesign.
Then, you have to select the page on which you want to paste the asset.

tell application "Adobe InDesign 2023"
	set assetRef to asset "Compuweigh" of library "zLibrary.indl"
	set placedAsset to (place asset assetRef on active document)
end tell

(And please, enter 3 ticks ``` before and after your code to have it formatted)

thanks…
that works for me…

I tried various things first…
then I actually used ChatGPT to write the code above…

I was hoping it could figure out what I was doing wrong.

I assume that if I wanted that asset on page 2, i would change it to read
set placedAsset to (place asset assetRef on page 2 of active document)

david