# Submit custom ID via form plus redirect

**URL:** <https://community.hubspot.com/t/submit-custom-id-via-form-plus-redirect/83291>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [June 13, 2023, 5:10pm UTC](https://community.hubspot.com/t/submit-custom-id-via-form-plus-redirect/83291 "2023-06-13T17:10:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evelliQM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/evelliqm/32/79180_2.png) [@evelliQM](https://community.hubspot.com/u/evelliQM)\
**Post date:** [June 13, 2023, 5:10pm UTC](https://community.hubspot.com/t/submit-custom-id-via-form-plus-redirect/83291/1 "2023-06-13T17:10:49Z")

</div>

I’m trying to pass a value through a form field via the embed code, along with doing a custom redirect. I see the documentation says to use OnFormSubmitted for the redirect, but this seems to work fine, not sure if it’s needed:

```lia-code-sample
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js">
</script>
<script> 
hbspt.forms.create
({ region: "na1",
portalId: "XXXXXX",
formId: "XXXXXX-XXXXXX-XXXXXX-XXXXXX",
redirectUrl: "https://www.redirectgoeshere.com/"
}); 
</script>

```

But I’m stuck on passing the value - I have only found threads discussing passing values based on form inputs which isn’t necessary for my case. The field is called recent\_asset\_id.

```lia-code-sample
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js">
</script>
<script> 
hbspt.forms.create
({ region: "na1",
portalId: "XXXXXX",
formId: "XXXXXX-XXXXXX-XXXXXX-XXXXXX",
redirectUrl: "https://www.redirectgoeshere.com/",
recent_asset_id: "test"
}); 
</script>

```

Any help appreciated

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [June 13, 2023, 5:53pm UTC](https://community.hubspot.com/t/submit-custom-id-via-form-plus-redirect/83291/2 "2023-06-13T17:53:30Z")

</div>

Hi @evelliQM ,

If you add the ‘recent\_asset\_id’ property as an hidden input to the form, you should be able to do this:

```lia-code-sample
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js?pre=1"></script>
<script>
 hbspt.forms.create({
 region: "na1",
 portalId: "XXXXXX",
 formId: "XXXXXX-XXXXXX-XXXXXX-XXXXXX",
 redirectUrl: "https://www.redirectgoeshere.com/",
 onFormSubmit: ($form) => {
 const assetIdInput = document.querySelector('[name="recent_asset_id"]');
 if (assetIdInput) {
 assetIdInput.value = "test";
 assetIdInput.dispatchEvent(new Event('input', { bubbles: true }));
 }
 },
 });
</script>

```
