# \[DONE\] About using entity fields

**URL:** <https://community.fibery.io/t/done-about-using-entity-fields/4398>\
**Category:** Get Help\
**Created:** [May 2, 2023, 5:30pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398 "2023-05-02T17:30:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 5:30pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/1 "2023-05-02T17:30:54Z")

</div>

Hello, everyone.

I need to transfer data from the RichText field of an entity in one database to a formula that I run in another database using Button.

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

A formula is nothing more than a text with a prompt for the AI, which will use RT1 as one of the elements of the prompt.

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

How do I do this?

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 5:38pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/2 "2023-05-02T17:38:16Z")

</div>

I asked GPT-3.5 from the Fibery interface 😀. He suggested this solution - insert Markdown markup:

{{#find “00cd1a20-e433-11ed-9262-53adc0ca5a59”}}  
{{Product}}  
{{/find}}

But an error occurs:  
Test is failed. Failed to execute Action “Overwrite Test”: Identifier directly after number (87:24)

---

<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 2, 2023, 6:07pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/3 "2023-05-02T18:07:18Z")

</div>

If you want to transfer data (incl rich text content) from an entity in db1 to one in db2, then there typically needs to be a connection between the dbs.  
What is the meaning behind the transfer in your case?  
Can you make the example concrete

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:15pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/4 "2023-05-02T18:15:55Z")

</div>

I am setting up automation in database 2. The automation replaces one of the RichText fields with the result of the AI.  
To do this, a prompt is made in the automation. Here I need to specify the content of the RichText field of one of the entities from database 1.  
The whole process is shown in the images above

---

<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 2, 2023, 6:16pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/5 "2023-05-02T18:16:45Z")

</div>

How are db1 and db2 related?

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:18pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/6 "2023-05-02T18:18:40Z")

</div>

With relation ))). Many to Many

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:22pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/7 "2023-05-02T18:22:30Z")

</div>

My task has already been described earlier here.

> [@\[DONE\] Add {{input}} into "Ask anything" option only when some text is selected](https://community.fibery.io/t/done-add-input-into-ask-anything-option-only-when-some-text-is-selected/4273):
>
> @mdubakov some extra feedback while actually working with AI chat. I often ‘just have a question’. So when I’m writing a question pops up in my mind. Like “what are the reasons that somebody doesn’t want to work with Calendly?” It’s awesome that I can ask that question directly in Fibery since it saves me a lot of time. Only problem is that the prompt always includes “{{input}}” Because of that, I can only ask non-context related questions when I’m at the top of my document. Is it …

That’s what I really need. The need to mention entities is one solution that came to mind.

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:24pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/8 "2023-05-02T18:24:12Z")

</div>

The idea is to add data from different databases to the AI prompt.

---

<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 2, 2023, 6:32pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/9 "2023-05-02T18:32:15Z")

</div>

If the relation is many-to-many, how does an automation in db2, know which entity in db1 it should be extracting the rich text content from?

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:38pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/10 "2023-05-02T18:38:27Z")

</div>

That’s also a question. Because need a relation «many to many».

But in fact the question is quite different. I wrote above.

«to add data from different databases to the AI prompt.»  
Any solution can be a solution. If there is one, of course.

---

<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 2, 2023, 6:41pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/11 "2023-05-02T18:41:13Z")

</div>

Well, the short answer is that AI can’t currently be used to populate from rich text fields.  
But I had hoped by digging into the details we might be able to find a workaround, but that seems unlikely.

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:47pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/12 "2023-05-02T18:47:39Z")

</div>

Filling RichText with AI is possible within a single database. To do this, just use «Automations» — «Button» — «Overwrite Field» — Prompt with [ai][/ai].  
But… «to add data from different databases to the AI prompt» — I haven’t figured out a solution yet ))).

Thank you for taking the time to find a solution 😉

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:49pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/13 "2023-05-02T18:49:57Z")

</div>

There is an idea to take data from documents created in Space. But I haven’t found what the syntax of such a request should be in Markdown.

---

<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 2, 2023, 6:51pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/14 "2023-05-02T18:51:28Z")

</div>

Sorry, I missed a word:  
‘populate _from_ rich text fields’

(I’ve update my reply above)

and actually, it is not related to AI - in general, automations can’t extract rich text from linked collections

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:51pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/15 "2023-05-02T18:51:29Z")

</div>

There seems to be a hint in this article.

[https://the.fibery.io/search/kiiZP#User\_Guide/Guide/Markdown-templates-53](https://the.fibery.io/search/kiiZP#User_Guide/Guide/Markdown-templates-53)

But I’m not good at JavaScript.

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 2, 2023, 6:52pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/16 "2023-05-02T18:52:51Z")

</div>

So we’ll wait for Fibery updates. ))

---

<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 2, 2023, 6:54pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/17 "2023-05-02T18:54:32Z")

</div>

> [@aklavrov](#):
>
> There seems to be a hint in this article.
> 
> [. | Fibery](https://the.fibery.io/search/kiiZP#User_Guide/Guide/Markdown-templates-53)
> 
> But I’m not good at JavaScript.

Well, if you want to do it with scripting, it may be possible. For example, you could use a script to populate the rich text field in db2 with the contents of the rich text fields of the linked entities in db1, and then use AI to take this description and overwrite the description with the output.  
But there’s not a no-code solution.

---

<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 2, 2023, 7:05pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/18 "2023-05-02T19:05:19Z")

</div>

Something like this might work:

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

Here’s the script (which you’ll need to modify according to your database and field names.

```auto
const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {
   
    const entityPlus = await fibery.getEntityById(entity.type, entity.id, ['Description','Sources']);
    const sources = await fibery.getEntitiesByIds('Source', entityPlus['Sources'].map((s) => s.id), ['Description'])
    await fibery.setDocumentContent(entityPlus['Description']['Secret'], '')
    for (const source of sources) {
        const sourceDesc = await fibery.getDocumentContent(source['Description']['Secret']);
        await fibery.appendDocumentContent(entityPlus['Description']['Secret'],sourceDesc)
    }
}

```

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 3, 2023, 6:26am UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/19 "2023-05-03T06:26:43Z")

</div>

Thank you very much. I will definitely give it a try.

---

<div class="post-metadata">

**Author:** ![aklavrov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/aklavrov/32/6715_2.png) [@aklavrov](https://community.fibery.io/u/aklavrov)\
**Post date:** [May 3, 2023, 3:05pm UTC](https://community.fibery.io/t/done-about-using-entity-fields/4398/20 "2023-05-03T15:05:48Z")

</div>

I found a solution to my problem. It was on the surface. No code 😀 .  
It’s probably obvious to experienced Fibery users. But no one suggested it. So I had to look it up. 🕶

Here’s everything we need: 2 databases, some RichText fields, the right relations.

The conditions of the problem in the form of screenshots were indicated in my question.  
Here’s the solution:

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

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

Relations determine which data will be used in the Prompt.  
This solution allows us to pull data only from the entities we need. Not a complete list of all field values of all entities in the database.

While in the DB2 database, we select the entity where we want to generate a response from the AI. And it is generated based on the DB1 database data that is defined by relation.

I’m happy. 😅

[Next page](https://community.fibery.io/t/done-about-using-entity-fields/4398.md?page=2)
