Javascript API - setting relative asset metadata field different for User and Backend User


(Lisa) #1

I’m having issues with how a related asset field is set using JS API when the user is a regular User vs a Backend User. If I try and set the field value with multiple asset IDs as a JSON encoded object, the same script encodes the data (and doesn’t work) when run as a User but works fine as a Backend User.

In the Metadata Field Updated logs I can see it sets the value to something like this when run as a Backend User:
"["148259","148131"]"
But sets it to this when run as a User:
"["148259","148131"]"

Has anyone come across this before?

Matrix Version: 5.5.1.5


(John gill) #2

Haven’t seen that before, but replicated in 5.5.1.5. It’s super weird, must be some kind of parsing difference but I can’t think why that would be.

As a workaround, using numeric assetids instead of strings - "[148259,148131]" - should work as long as you’re dealing with real assets and not shadow assets, and cuts out the quotes that are being misinterpreted.


(Lisa) #3

I think this is actually working now. I’ve been trying all different variations of arrays, permissions, setMetadata vs setMetadataAllFields, single functions vs batched, I don’t know how I missed this?! *face palm*