# Need assistance with correct Hubl code

**URL:** <https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554>\
**Category:** CMS Development\
**Created:** [September 29, 2021, 2:49pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554 "2021-09-29T14:49:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmcmillan99](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tmcmillan99/32/93181_2.png) [@tmcmillan99](https://community.hubspot.com/u/tmcmillan99)\
**Post date:** [September 29, 2021, 2:49pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/1 "2021-09-29T14:49:26Z")

</div>

I need some assistance in determining the correct Hubl code for my scenario below. I am trying to grab part of a request query to use as the customer id in order to pull data from a HubDB table. The code was working correctly but I believe I broke it when adding an additonal parameter (assigned\_dealer\_v2=) to the requst query to be used in a hidden form field.

Example Request Query from the URL-

/dealer?assigned\_dealer\_v2=Indeco%20Sales&id=00010928-tx

My Hubl Code-

{% set dealer = ‘{{ request.query|split(“=”)|last|trim }}’ %}  
{% set dealerval = dealer|render %}  
{% for row in hubdb\_table\_rows(5241455, ‘customerid=’~dealerval) %}

Using the example request query above, I am trying to pull the string after the last “=” sign - 00010928-tx

Any ideas on what I have set up wrong?

Thanks,

Terry McMillan

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [September 29, 2021, 4:10pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/2 "2021-09-29T16:10:43Z")

</div>

Hello @tmcmillan99 , can you output the dealer id with a `{{dealerval}}` so that we can see that the correct value is pulled off the request query?  
I used your exact code and it does indeed pull the “00010928-tx” value.  
Maybe the issue is with the hubdb.

---

<div class="post-metadata">

**Author:** ![tmcmillan99](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tmcmillan99/32/93181_2.png) [@tmcmillan99](https://community.hubspot.com/u/tmcmillan99)\
**Post date:** [September 29, 2021, 4:16pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/3 "2021-09-29T16:16:15Z")

</div>

@miljkovicmisa Thanks for the reply back and confirmation that the code is working as it should. I have not looked at the HubDB table yet. It was recently updated by the client so that will definitely be my next step.

Thanks for the assistance.

Terry

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [September 29, 2021, 6:14pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/4 "2021-09-29T18:14:25Z")

</div>

Hey @tmcmillan99

It might be easier to use request.query\_dict. This variable breaks all querys into a dictionery thats much easier to use.

```lia-code-sample
{% set the_query = request.query_dict %}

{% set dealer = the_query.id %}

```

With this method you can also handle situations when the query isn’t present.

```lia-code-sample
{% if !the_query.id %}
 Somthing went wrong
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![tmcmillan99](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tmcmillan99/32/93181_2.png) [@tmcmillan99](https://community.hubspot.com/u/tmcmillan99)\
**Post date:** [September 29, 2021, 6:22pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/5 "2021-09-29T18:22:34Z")

</div>

Awesome @Kevin-C.

Thanks for the suggestion! I have not seen that variable before so I will definitely look into more.

---

<div class="post-metadata">

**Author:** ![tmcmillan99](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tmcmillan99/32/93181_2.png) [@tmcmillan99](https://community.hubspot.com/u/tmcmillan99)\
**Post date:** [September 30, 2021, 1:25am UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/6 "2021-09-30T01:25:29Z")

</div>

**Update** - I have still not been able to get it to work correctly. I am sure it’s going to be something simple. I changed up the code a bit to make it easier to see what value is being rendered if I output it to the page.

New Code-

```lia-code-sample
{% set dealer = '{{ request.query|split("=")|last|trim }}' %}
{% set dealerval = 'customerid='~dealer|render %}
{% for row in hubdb_table_rows(5241455, dealerval) %}

```

If I output {{ dealerval }} on the page, it shows a value of ‘customerid=00010928-tx’ which is correct and should filter the table to those rows that match.

If I manually input the info for dealerval as such:

`{% set dealerval ='customerid=00010928-tx' %}`

Everything works correctly and it pulls the appropriate info from the row and displays it on the page.

Any additional thoughts or suggestions would be greatly appreciated.

Thanks,

Terry

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [September 30, 2021, 10:32am UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/7 "2021-09-30T10:32:15Z")

</div>

@tmcmillan99

Your first line setting and assigning the dealer variable is invalid. Remove the quotation marks and remove the brackets. It should be:

`{% set dealer = request.query|split("=")|last|trim %}`

---

<div class="post-metadata">

**Author:** ![tmcmillan99](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tmcmillan99/32/93181_2.png) [@tmcmillan99](https://community.hubspot.com/u/tmcmillan99)\
**Post date:** [September 30, 2021, 1:24pm UTC](https://community.hubspot.com/t/need-assistance-with-correct-hubl-code/44554/8 "2021-09-30T13:24:38Z")

</div>

@piersg That was the issue! Thanks so much for the suggestion. The issue is resolved and the data is displaying correctly now. Much appreciated.

Terry
