I have created an Html form on my marketing cloud landing page and I am creating a lead on the form submission using CreateSalesforceObject() function. All the form fields are being captured well except one checkbox field. I am using the request parameter to fetch the checkbox value but it's giving me error500. Can anybody help me how to resolve this issue?
My guess is that you need to define a true or false value.
If your HTML looks like this:
<input type="checkbox" name="consent" value="true">
Then in your AMPscript code block, use the following syntax (obviously change the arguments as required):
var @consent, @createLead set @consent = iif(RequestParameter('consent')==true,'true','false') set @createLead = CreateSalesforceObject( "Lead", 5, "FirstName", RequestParameter("firstname"), "LastName", RequestParameter("lastname"), "Company", RequestParameter("company"), "Email", RequestParameter("email"), "Consent__c", @consent )