# Script filter not returning entity that was created in previous loop

**URL:** <https://community.fibery.io/t/script-filter-not-returning-entity-that-was-created-in-previous-loop/6311>\
**Category:** Get Help\
**Created:** [June 18, 2024, 5:03pm UTC](https://community.fibery.io/t/script-filter-not-returning-entity-that-was-created-in-previous-loop/6311 "2024-06-18T17:03:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![interr0bangr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/interr0bangr/32/8089_2.png) [@interr0bangr](https://community.fibery.io/u/interr0bangr)\
**Post date:** [June 18, 2024, 5:03pm UTC](https://community.fibery.io/t/script-filter-not-returning-entity-that-was-created-in-previous-loop/6311/1 "2024-06-18T17:03:22Z")

</div>

We have a script that does the following:

1. Takes the full URL of a page from an XML file and breaks all the slugs into an array.

For example:  
Full URL: [http://www.fibery.io/page1/page2/page3](http://www.fibery.io/page1/page2/page3)  
Slug Array: page1, page2, page3

1. Checks the first slug in the array to see if a Page with a matching “Parent Page” and “Page Path” field exists.

Parent Path is the following formula: If(IsEmpty([Parent Page]), “”, [Parent Page].[Page Path])  
Page Path is the following formula: Parent Path + “/” + Slug

For example:  
Loop 1:  
Slug: page1  
Parent Path:  
Page Path: page1

Loop 2:  
Slug: page2  
Parent Path: page1  
Page Path: page1/page2

Loop 3:  
Slug: page3  
Parent Path: page1/page2  
Page Path: page1/page2/page3

1. If no match is found, create new entity, and then loop on the next slug in the array.

We’re having an issue in Loop 2 and beyond, were no matches are being found for “Parent Path” even though we know the parent was created and linked in the previous loop.

Is this because we’re using formulas for our 2 path fiends and the formulas are not being generated quickly enough to be populated before the next entity search happens? Or is there another thing at play?

---

<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:** [June 18, 2024, 8:57pm UTC](https://community.fibery.io/t/script-filter-not-returning-entity-that-was-created-in-previous-loop/6311/2 "2024-06-18T20:57:36Z")

</div>

> [@interr0bangr](#):
>
> Is this because we’re using formulas for our 2 path fiends and the formulas are not being generated quickly enough to be populated before the next entity search happens?

Probably this
