Request Checkbox on submit | Community
Skip to main content

Request Checkbox on submit

  • October 12, 2021
  • 3 replies
  • 0 views

Good morning, don't know if somebody can help me on this.

i presently use something like this = $('#request_custom_fields_1260825969349').val(); to request value of a custom field on submit. I then can add the value in that text box into the description.

What method would i use  for checkbox.

I am looking to see if on submit the checkbox is checked or not checked

3 replies

Tipene
  • October 13, 2021

Hi @Patrick Bernardi,

Thanks for reaching out!

You can use the ticket object to access the value of the checkbox, so something like this could work:

client
.get("ticket.customField:custom_field_1260825969349")
.then(data => console.log(data));

This will return a string of ‘yes’ or ‘no’ depending on if the checkbox has been checked or not.

Here’s a link to the relevant docs:

https://developer.zendesk.com/api-reference/apps/apps-support-api/ticket_sidebar/#ticketcustomfieldfieldname

Alternatively, you can also set the custom field to ‘required’ in your Zendesk instance UI. Here’s some information on how to do that:

https://support.zendesk.com/hc/en-us/articles/203661496-Adding-custom-fields-to-your-tickets-and-support-request-form

I hope this helps! If you have any questions, feel free to reach out.

Tipene


  • Author
  • October 13, 2021

I am programming this in the script.js file, this code will work in there?

see sample below of what i presently do

 

function checkitsupportrequiredfields() {
var strITTopicReq = $('#request_custom_fields_1260812850530').val();
var strITDescriptionReq = $('#request_custom_fields_1260812850510').val();
var strITDescriptionReqLength = $('#request_custom_fields_1260812850510').val().length;
if (strITTopicReq != "" && strITDescriptionReqLength > 3) {
$(':input[type="submit"]').prop('disabled', false);
$('#request_description').val(strITDescriptionReq);
} else {
$(':input[type="submit"]').prop('disabled', true);
$('#request_description').val(strITDescriptionReq);
}
}


Tipene
  • October 14, 2021

Hi @Patrick Bernardi,

Yes, there shouldn't be any problem using the method I mentioned above in your code. If you'd like to send me the relevant files though, I can double-check that for you. Just be sure to redact any sensitive information.

Thanks!

Tipene