# How can I add record data to the URL prefix in the file viewer?

**URL:** <https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138>\
**Category:** Help me!\
**Created:** [October 15, 2020, 1:35pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138 "2020-10-15T13:35:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 15, 2020, 1:35pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/1 "2020-10-15T13:35:33Z")

</div>

This seems like a common scenario but I wasn’t able to find info in the docs.

How can I add to the url prefix data from the record being displayed? So I need to substitute in the URL prefix the field id from the record.

![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/8325a03db73712e7d0fa9c0dd8f24b55d1c6cb53.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![rap2h](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/rap2h/32/25_2.png) [@rap2h](https://community.forestadmin.com/u/rap2h)\
**Post date:** [October 15, 2020, 3:02pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/2 "2020-10-15T15:02:14Z")

</div>

Hi @jonl 👋

The value of your field is actually appended after the prefix of the URL.

So assuming your field value is `1234` and the prefix is `https://my-prefix/folder/` the URL of your file viewer will be `https://my-prefix/folder/1234`.

👉 If you want to add additional data (such as item ID + some other value separated with a slash), you have to handle it in your database (i.e: save the whole string with all the info needed) or use a [smart field](https://docs.forestadmin.com/documentation/reference-guide/fields/create-and-manage-smart-fields)

In other words, Forest Admin UI takes the field value as-is, and append it at the end of the URL. Still you can choose [_what_ your backend returns](https://docs.forestadmin.com/documentation/reference-guide/fields/create-and-manage-smart-fields) to the UI when it ask for item values.

---

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 15, 2020, 4:25pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/3 "2020-10-15T16:25:45Z")

</div>

Unfortunately that is not an option. I would have to redo a lot of logic in my app.

This seems quite an omission if it’s not possible.

---

<div class="post-metadata">

**Author:** ![anon36130554](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@anon36130554](https://community.forestadmin.com/u/anon36130554)\
**Post date:** [October 16, 2020, 12:34pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/4 "2020-10-16T12:34:33Z")

</div>

Hello @jonl 👋

The workaround @rap2h gave you is quite easy to implement.

In your collection you would just need to create a smart field such as the following:

```javascript
collection('myCollection', {
  actions: [],
  fields: [{
    field: 'image_link',
    type: 'String',
    get: (record) => {
      return record.originalLinkAttribut + record.id;
    },
  }],
  segments: [],
});

```

Then configure this field in your UI the same way you did for `originalLinkAttribut` and you will be ready to go 👍

You could then hide the `originalLinkAttribut` field to not pollute your layout.

With this, the url will be computed correctly and your images should be accessible.

Tell me if this helps out, or if you have any question 😃

Steve.

---

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 16, 2020, 2:46pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/5 "2020-10-16T14:46:00Z")

</div>

I must admit that I did a quick read of his second paragraph and missed completely the “smart field” workaround. I just read make the change in the DB and was disappointed. Should have read more and better.

Thanks both of you guys. A smart field is indeed an option that we can consider.

Edit: Just to confirm that the solution proposed works perfectly. I had to add some additional logic that I didn’t mention, but everything is peachy. Thanks again @rap2h and @anon36130554

---

<div class="post-metadata">

**Author:** ![anon36130554](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@anon36130554](https://community.forestadmin.com/u/anon36130554)\
**Post date:** [October 16, 2020, 3:23pm UTC](https://community.forestadmin.com/t/how-can-i-add-record-data-to-the-url-prefix-in-the-file-viewer/1138/6 "2020-10-16T15:23:12Z")

</div>

We are glad the solution suits your need 🎉🎊

Thanks for the update and for posting on the community 🙏

Steve.
