Code for hook to capture URL from a submitted contact form and display it in the dataset entry

Hi there,

I have a contact form linked to a dataset. When the contact form is submitted, I am looking to capture the full page URL, so the page URL displays in a field (which I have already created) in the dataset entry.

I understand I need to use the beforeInsert hook below:

export function myCollection_beforeInsert(item, context) {
  
  item.urlfield = ...

  return item;
}

Where the … is, what code should appear here?

Thanks in advance for your help.

Cheers,
Cameron

https://www.wix.com/corvid/reference/wix-location.html#url
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue

Isn’t this the same as you asked earlier today?
https://www.wix.com/corvid/forum/community-discussion/implementing-code-capturing-url-from-contact-form-on-listing-item

See previous forum posts about a similar question.
https://www.wix.com/corvid/forum/community-discussion/save-url-current-automatically