Using Special Characters in Query String
1 minute to readQuery String is a great way of passing parameters from one DataPage to another. However, in some cases, values may contain special characters or symbols that may cause issues with passing them to DataPages. This issue can be avoided by encoding the special characters using Caspio Calculated Field before using them in Query String.
Prerequisites:
This method requires one Calculated Field for each Data Source field.
Steps:
- Replacing a special character:
replace([@field:FIELDNAME],’#’,’%23′)
- Replacing multiple special characters with cascading Replace function:
replace(replace([@field:FIELDNAME],’=’,’%3D’),’&’,’%26′)
The values can be safely passed to your Query String after they are encoded. For example:
https://www.site.com/page.html?parameter1=[@calcfield:1]
Character Encoding
Since Caspio utilizes UTF-8 encoding on the DataPages, we can convert these special symbols to their UTF-8 counterparts. Below is the initial list of special characters that can cause issues when passing them to Query String:
Character | From UTF-8 |
---|---|
Space | %20 |
! | %21 |
“ | %22 |
# | %23 |
$ | %24 |
% | %25 |
& | %26 |
‘ | %27 |
* | %2A |
+ | %2B |
, | %2C |
/ | %2F |
= | %3D |
? | %3F |
To see the full list of special characters, visit w3schools.org.