# Slices and linked document fields

**URL:** <https://community.prismic.io/t/slices-and-linked-document-fields/5508>\
**Category:** Developing with Prismic\
**Created:** [May 25, 2021, 2:59pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508 "2021-05-25T14:59:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![delon.steph](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@delon.steph](https://community.prismic.io/u/delon.steph)\
**Post date:** [May 25, 2021, 2:59pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/1 "2021-05-25T14:59:12Z")

</div>

Hi there,

I am trying to create in a separate function all the slices available on my site to retrieve them when needed. So far so good, but when trying to get the fields of the linked document fields, I get a [[PromiseResult]] and can't get the data. I am learning Prismic for a couple days only and so I am probably doing something wrong here, but since I can log the values correctly, I don't get what is wrong. I can console.log them but can't access them. Here is the part of the function I am talking about :

* * *

const getSlices = page =\> {  
return page.data.body.map(slice =\> {  
switch(slice.slice\_type) {  
case 'concept\_clef':  
return {  
conceptClef: {  
titre: slice.primary.titre\_section,  
intro: slice.primary.intro\_section  
}  
}  
case 'list\_of\_articles':  
return {  
listArticles: {  
titre: slice.primary.titre\_section,  
intro: slice.primary.intro\_section,  
articles: slice.items.map(async item =\> {  
return await Client.getByID(item.articles\_to\_link.id)  
})  
}  
}  
})  
}

Thanks for your help !

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [May 26, 2021, 10:12am UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/3 "2021-05-26T10:12:31Z")

</div>

Hello Stephanie,

Thanks for posting this question to us.

You need to use fetchLinks in your code. fetchLinks fetches a specific content field from a linked document. Find more detail [here](https://prismic.io/docs/technologies/fetch-linked-document-fields-javascript). This is in javascript but you can find documentation in the different frameworks as well.

You need to use fetchLinks in your code. In your `fetchLinks` array, the value should be:

- First, the API ID of the custom type referenced in your content relationship field.
- Then, the API ID of the field that you want to retrieve.

Let me know if it doesn't work for you, we can work together to solve this.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![delon.steph](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@delon.steph](https://community.prismic.io/u/delon.steph)\
**Post date:** [May 26, 2021, 11:05am UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/4 "2021-05-26T11:05:21Z")

</div>

Hi and thanks Priyanka for your kind return ! I already went on the link you shared with me, but the fields I am accessing are in a slice zone and the page you shared mentions that "It is not possible to retrieve the following content field types: Any field in a Group or Slice".

So I found the workaround below in order to access the data anyway to use them in my template and it works great but I wonder if it is ok for Prismic though.

articles: slice.items.map(item =\> {  
let results =   
Client.getByID(item.articles\_to\_link.id).then(res =\> results.push(res))  
return results  
})

Thanks !

---

<div class="post-metadata">

**Author:** ![delon.steph](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@delon.steph](https://community.prismic.io/u/delon.steph)\
**Post date:** [May 26, 2021, 12:36pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/5 "2021-05-26T12:36:30Z")

</div>

@Priyanka, I might have not been precise in my answer but if there is a way to retrieve content field types in a slice group, it would be fantastic if you could share the way to get all this working. To be more precise on what I am trying to get : I am linking 4 articles on the homepage and the api only retrieve the id of the article, where I would need the title, excerpt, image...  
Thanks !

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [May 27, 2021, 9:20am UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/6 "2021-05-27T09:20:49Z")

</div>

To retrieve linked documents from Slices, you need to use graphQuery. It's an advanced version of fetchLinks.  
Please follow this doc: [API reference for GraphQuery (fetchLinks v2) - Prismic](https://prismic.io/docs/technologies/graphquery-rest-api)

Let me know if you have any doubt.

Thanks,

Priyanka

---

<div class="post-metadata">

**Author:** ![delon.steph](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@delon.steph](https://community.prismic.io/u/delon.steph)\
**Post date:** [May 27, 2021, 12:43pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/8 "2021-05-27T12:43:28Z")

</div>

That made the trick 🙂 Thanks Priyankaa for your help !

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [May 27, 2021, 1:18pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/9 "2021-05-27T13:18:33Z")

</div>

Hello Stephanie,

I am glad that It works for you. Don't hesitate to reach out to us with any questions.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [May 28, 2021, 1:18pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/10 "2021-05-28T13:18:55Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 12:03pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/11 "2021-12-09T12:03:46Z")

</div>



---

<div class="post-metadata">

**Author:** ![codingspark](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/codingspark/32/2389_2.png) [@codingspark](https://community.prismic.io/u/codingspark)\
**Post date:** [January 24, 2023, 10:59am UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/12 "2023-01-24T10:59:48Z")

</div>

There is no way to retrieve linked documents from slices using `fetchlinks` without the graphQuery ? THis is mandatory ?

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [January 24, 2023, 12:10pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/14 "2023-01-24T12:10:02Z")

</div>

Hello Andreas,

fetchLinks can _not_ retrieve the following fields:

- Embed
- GeoPoint
- Link
- Link to Media
- Rich Text (anything other than the first element)
- Any field in a Group or Slice

So you need to use graphQuery to fetch content from Slices. Are you getting any trouble in using graphQuery? I'll be happy to assist you.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gijs](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/gijs/32/4212_2.png) [@gijs](https://community.prismic.io/u/gijs)\
**Post date:** [March 16, 2023, 3:16pm UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/16 "2023-03-16T15:16:08Z")

</div>

@Priyanka I'm struggling to resolve some data with either fetchLinks or graphQuery.  
I have a content type `landingPage` which has the key text field `slug`. In that content type I use a slice called `TextBlock`. This slice has a rich text field. In that field I've added a link to a different `landingPage` document.  
I'm unable to resolve the slug field for the linked landingPage inside the slice's rich text field. Could you explain how it could be done?

---

<div class="post-metadata">

**Author:** ![gijs](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/gijs/32/4212_2.png) [@gijs](https://community.prismic.io/u/gijs)\
**Post date:** [March 17, 2023, 8:54am UTC](https://community.prismic.io/t/slices-and-linked-document-fields/5508/17 "2023-03-17T08:54:47Z")

</div>

@Priyanka Sorry, I was just stupid. I used `getFirst` and put the fetchLink and lang in a second parameter, that doesn't exist. it's working fine!
