How to get Documents secret in script?

I’m just trying to figure out how to retrieve the secret for a Documents collection.
This is not working - always gets null:

1 Like

Not sure if this is what you are looking for

for (const entity of args.currentEntities) {
    const [assignees, summary] = await Promise.all([

taken from Fibery GitLab

@Matt_Blais The construction you have used would work fine for rich text fields, but the Documents collection works slightly differently.
It returns an array of ‘views’ and you need to look at the meta data for each of them to get the document secret.

The syntax should be something like this:

const doc0 = entity['Documents'][0];
const docView = await fibery.getEntityById('fibery/view',, ['fibery/meta']);
const docSecret = docView['fibery/meta']['documentSecret'];

Thanks @Chr1sG!

Related: Update a linked Document by prepending the contents of Rich Text fields