# Scripting with a self-relating database

**URL:** <https://community.fibery.io/t/scripting-with-a-self-relating-database/4091>\
**Category:** Get Help\
**Created:** [March 3, 2023, 3:37am UTC](https://community.fibery.io/t/scripting-with-a-self-relating-database/4091 "2023-03-03T03:37:29Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [March 4, 2023, 9:07pm UTC](https://community.fibery.io/t/scripting-with-a-self-relating-database/4091/10 "2023-03-04T21:07:58Z")

</div>

I just figured it out! I sifted through old API & Programming threads and found [this](https://community.fibery.io/t/script-equivalent-of-the-convert-to-feature/2296) as a solution. The modified script looks like this:

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

for (const entity of args.currentEntities) {
    await fibery.createEntity("Estimate System Test/Material Pricing", {
        "Code": entity["Code"],
        "Cost": entity["Current Average"],
    });
}

```

Thank you @Chr1sG and @tpaktop for your help! I will leave to template link to the space if anyone wants to mess with it, I think it turned out pretty cool! [Estimate System Test — Fibery](https://shared.fibery.io/t/99d0c902-4c33-44a0-a528-f9b970f5f250-estimate-system-test)

---

_[View the full topic](https://community.fibery.io/t/scripting-with-a-self-relating-database/4091)._
