URL Param Value presenter - data being overwritten

I am using the URL Param Value presenter to take a parameter in the url and save it to a field in the data object. This is working fine as when you open the link the parameter is shown on the page and when you click next to go to the second page it is saved to the data object.
However if you then go back to the first page the field on the page is blank, i presume because the parameter is no longer in the url. Now if you go to the second page the field is saved as blank in the data object.
How do i stop this?
Thanks

Sounds like you need to just add some logic around how the value is determined in the URL Param Value presenter.

I would change your get_template_data function to something like:

get_template_data: function() {

		let currentValue = presenter.get_editable_value();
		let paramValue = cs.url_param(presenter.get_setting("parameter_key"));

		let value = currentValue;

		if (paramValue) {
			if (currentValue != paramValue) value = paramValue;
		}
		
		
		return {
			value
		}
	},

That way if the property already has a value and the url parameter is missing it doesn’t change it. But if the url parameter is present and different to the current value it will update it.

I would recommend updating it for your own required logic.

1 Like

Neil
Thanks that is working .