# Any way to get the refId in a sitemap from a URL string at valve level?

**URL:** <https://community.bloomreach.com/t/any-way-to-get-the-refid-in-a-sitemap-from-a-url-string-at-valve-level/2613>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [June 7, 2021, 11:00pm UTC](https://community.bloomreach.com/t/any-way-to-get-the-refid-in-a-sitemap-from-a-url-string-at-valve-level/2613 "2021-06-07T23:00:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmrodriguez](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jmrodriguez](https://community.bloomreach.com/u/jmrodriguez)\
**Post date:** [June 7, 2021, 11:00pm UTC](https://community.bloomreach.com/t/any-way-to-get-the-refid-in-a-sitemap-from-a-url-string-at-valve-level/2613/1 "2021-06-07T23:00:44Z")

</div>

Hi!

We know we can get the refId for a given request at valve level by doing

```auto
valveContext.getRequestContext().getResolvedSiteMapItem().getHstSiteMapItem().getRefId()

```

but that applies in the context of the the current request being processed.

What if I wanted to know the refId of another url that is not the one currently being processed by the valve, by having its url?

For instance, for the next request:

[http://myinstance.com/site/somepath/mypage?targetUrl=http%3A%2F%2Fmyinstance.com%2Fsite%2Fmytarget%2F123%3Fparam1%3Dvalue1](http://myinstance.com/site/somepath/mypage?targetUrl=http%3A%2F%2Fmyinstance.com%2Fsite%2Fmytarget%2F123%3Fparam1%3Dvalue1)

We would like to get the refId of the url passed in the targetUrl parameter, and NOT the one for the first part of the URL.

This gets particularly tricky as the targetUrl parameter could be in a sitemap that is defined in a configuration that is not the same where `mypage` is declared.

Asked more technically:

Is there any way to programmatically get all the sitemaps declared in all the configurations of my project and use a SitemapMatcher or similar to find the SiteMapItem that matches the targetUrl value so we can get the refId of THAT SiteMapItem?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [June 8, 2021, 9:47am UTC](https://community.bloomreach.com/t/any-way-to-get-the-refid-in-a-sitemap-from-a-url-string-at-valve-level/2613/2 "2021-06-08T09:47:56Z")

</div>

> [@jmrodriguez](#):
>
> What if I wanted to know the refId of another url that is not the one currently being processed by the valve, by having its url?

See `#matchSiteMapItem(..)` in [ResolvedMount (Hippo Site Toolkit API 14.6.0 API)](https://javadoc.onehippo.org/14.6/hippo-site-toolkit/org/hippoecm/hst/core/request/ResolvedMount.html#matchSiteMapItem-java.lang.String-)

---

<div class="post-metadata">

**Author:** ![jmrodriguez](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jmrodriguez](https://community.bloomreach.com/u/jmrodriguez)\
**Post date:** [June 8, 2021, 2:43pm UTC](https://community.bloomreach.com/t/any-way-to-get-the-refid-in-a-sitemap-from-a-url-string-at-valve-level/2613/3 "2021-06-08T14:43:24Z")

</div>

Thanks for the quick response @woonsanko

`valveContext.getRequestContext().getResolvedMount().matchSiteMapItem("THE_URL")` would certainly give a SiteMapItem that matches the url passed as parameter (if found) and I can get the refId from that object.

Thanks a lot  
Juan
