# How to get Documents secret in script?

**URL:** <https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808>\
**Category:** Get Help\
**Created:** [May 17, 2022, 7:28pm UTC](https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808 "2022-05-17T19:28:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [May 17, 2022, 7:28pm UTC](https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808/1 "2022-05-17T19:28:08Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/e/ed26ad2420051f044fc3e0348e15a95b998e7398.png)

---

<div class="post-metadata">

**Author:** ![cover](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/cover/32/11891_2.png) [@cover](https://community.fibery.io/u/cover)\
**Post date:** [May 17, 2022, 7:44pm UTC](https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808/2 "2022-05-17T19:44:17Z")

</div>

Not sure if this is what you are looking for

```nohighlight
for (const entity of args.currentEntities) {
    const [assignees, summary] = await Promise.all([
        getAssigneesSlackIds(entity.type, entity.id),
        api.getDocumentContent(entity["Summary"].secret)
    ]);

```

taken from [Fibery GitLab](https://gitlab.com/fibery-community/action-buttons/-/blob/master/send-to-slack/send-to-slack.js)

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [May 17, 2022, 7:46pm UTC](https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808/3 "2022-05-17T19:46:23Z")

</div>

@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:

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

```

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [May 17, 2022, 9:10pm UTC](https://community.fibery.io/t/how-to-get-documents-secret-in-script/2808/4 "2022-05-17T21:10:41Z")

</div>

Thanks @Chr1sG!

Related: [Update a linked Document by prepending the contents of Rich Text fields](https://community.fibery.io/t/update-a-linked-document-by-prepending-the-contents-of-rich-text-fields/2809)
