0

I have a CloudPage form which contains a Select Dropdown with a JSON-esque Value:

<select id="Select_Specialism" name="Select_Specialism" required=""><option value="">Select Specialism</option>
<option value="{'FileName':'Accounting','PDFURL':'http://CLIENTURL/lib/43244fdsffdsf/m/1/account.pdf'}">Accountancy &amp; Finance</option>

<option value="{'FileName':'Banking','PDFURL':'http://CLIENTURL/lib/43244fdsffdsf/m/1/banking.pdf'}">Banking &amp; Financial Markets</option> </select>

The form is submitted to a Processor CloudPage, which is SSJS :

var specialism = Request.GetFormField("Select_Specialism");

try {
      var obj = JSON.parse(specialism); // this is how you parse a string into JSON
      Write(Stringify(obj));
      var PDFDownloadLink = obj.FileName;
      var PDFFileName = obj.PDFURL;
    } catch (ex) {
      Write(Stringify(ex));
    }

I'm wanting to set PDFDownloadLink and PDFFileName from the Select value passed as JSON, however when I run this, I get a 500 Internal Server Error(there is a further process for logging to data extension and redirecting to PDF URL, but if PDFDownloadLink and PDFFileName are hardcoded with the values then it works)

Any observations of where I might be going wrong is appreciated.

1 Answer 1

2

I managed to solve this myself - I was using the incorrect function

 var obj = Platform.Function.ParseJSON(specialism);
 var FileName = obj.FileName;
 var PDFURL = obj.PDFURL;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .