Using NSMutableDIctionary to substitute LNS set property for key

I hope somebody can help me with this…
I already know replacements for string and records with the replacement of code where I used the LNS scripting addition set property X in Y for key Z…

Now I’m using
dictDataHeaderColumnIndex’s setValue:mValue forKey:mKey
and
set mKeyValues to (dictDataHeaderColumnIndex’s valueForKey:(mKey)) as [record | text]

But now I’m experiencing an issue where I want to add a InDesign object reference like ‘text field id 9348 of master spread id 186 of document id 257’ to such a dictionary in the same way but I always get the error:
Can’t make «class txtf» id 9348 of «class mspr» id 186 of document id 257 of application “Adobe InDesign 2021” into the expected type.

I already tried
dictDataHeaderColumnIndex’s setObject:(object reference of mTabCandidate) forKey:mKey)
without succes

Anybody any idea?
Thanks in advance! You don’t buy a bear with that… I know :slight_smile:

As you’ve seen, you can’t include object references from apps. However, the workaround in this particular case is to change your code slightly and just use the id, which is globally unique within an InDesign document.

Importantly, using ids lets you skip having to give the full object reference — or even worry about the class. Consider this code:

tell application id "com.adobe.InDesign" -- Adobe InDesign 2021.app
	set someStory to parent story of text frame 1 of document 1
	set theID to id of someStory
	set someStory2 to page item id theID of document 1
end tell

Although it’s asking for a page item, it ignores it and just returns the item with the correct id.

Thnx Shane! Again!

A small additional question regarding ASOC in a tell application part
It doesn’t seems to return the desired results…
Something like set allKeys to dictTabCandidates’s allKeys() as list returns a different result in the tell part than outside of it?

Very normal you will say?

You shouldn’t be calling the ASObjC stuff inside an application tell block. But I’m not sure what you’re saying…