Generate URL with encoded query

I am building a form which takes several inputs and then needs to build a url with an encoded query string based on the data submitted.
Can anyone suggest how I might go about this?


You can use Composites to achieve this.

Using the “Decode/Encode” function you can create a composite for each of the URL encoded values you need in your query.

Then a final Text based composite to chain them together into your desired URL.

An example composite which URL encodes a Text field…

Then using that composite in another one to create the URL…

1 Like

If you have a lot of fields to encode, making this too cumbersome, you could achieve the same in a Code Studio Event Action (or maybe Field Processor depending on where you need to use the finished link), to create the URL and save it to another Property field.

1 Like


Hi, I have had a go at creating the composites. I have set the link to refresh when “E1” happens and the fields in the form to trigger “E1”. But it is not updating.

If I submit & go back it has updated.


Ah, if you are trying to do this live on the page as the values change, then it would have to be done using Code Studio (a Fragment Callback for example).

Composites only work on the saved value, so as you have seen they will only update when you submit the form.

If you want to avoid Code Studio then could you move dispaying of the ink to a next page, i.e. complete the form and submit it, and then on the next page show the link?

1 Like

I would like the link to appear on the same page. I have set up a reference to one of my fields to test how to do this.
My callback code looks like this:

return {
	main: function(obj) {
		var values = obj.get_values();  
		if (!values) return;     
		let name = cs.ref('procurement_name');

It’s picking something up, but not displaying the value in the reference.
Sorry I have been reading the documentation and trying a few things out, but I am stuck.


You will need to extract the relevant form value(s) from the values array.

If you log this out to Detective you should see that it contains all the values from the form, indexed by their field path.


You can then use Reference(s) to pick out the ones you need and encode them. Something along these lines but the specifics will differ…

var values = obj.get_values();

var field1 = values[cs.ref('my_field_1')] ?? '';

var url = '' + encodeURIComponent(field1)
1 Like