Zendesk API Autofill ticketfield based on customfield
Publication le 17 oct. 2023
Dear Community,
I'm currently working on configuring our script.js file. Many of our formulas do not require customers to input any messages in the description field, which is why I have currently hidden this part. However, as this field is mandatory, I'm currently inputting a constant string "Custom Field text."
I would like to replace this constant text with a variable that depends on the customer's input in a customField. The text in the customField and the description field should be identical.
Here is my current code, which I borrowed from the community moderator, Ifra Saqlain
document.addEventListener("DOMContentLoaded", function () {
function checkTicketId(){
var descriptionWarpper = document.querySelector('.form-field.request_description');
var descriptionField = document.querySelector('#request_description');
var descriptionLabel = document.querySelector(".form-field.text.required.request_description > label");
var attachmentWarpper = document.querySelector('label[for="request-attachments"]');
var dropzoneWarpper = document.querySelector('#upload-dropzone');
descriptionWarpper.style.display= "block";
descriptionLabel.innerHTML = 'Beskrivelse';
if(window.location.href.indexOf('14154610162461' ) > 1) {
descriptionWarpper.style.display= "none";
descriptionField.innerHTML = "Custom Field text";
attachmentWarpper.style.display= "none";
dropzoneWarpper.style.display= "none";
} else if(window.location.href.indexOf('14154601112989') > 1) {
descriptionWarpper.style.display= "none";
descriptionField.innerHTML = 'Custom Field text';
attachmentWarpper.style.display= "none";
dropzoneWarpper.style.display= "none";
} else if(window.location.href.indexOf('14200136091677') > 1) {
descriptionWarpper.style.display= "none";
descriptionField.innerHTML = 'Custom Field text';
attachmentWarpper.style.display= "none";
dropzoneWarpper.style.display= "none";
}
}
checkTicketId();
});
0
4
4 commentaire
Mathias Katz Sørensen
Thank you so much! You are indeed a saint
Sorry for the late response, but i havent had the time to try out your solutions, but i works perfectly.
In the meanwhile i also got the need for beeing able to check off a checbox, whenever the input value is grater than 28. I made i work with checking off the checkbox, when you are typing the number, but whenever you are using your mouse to incrument the value inside the number-box, i will not effeect the checkbox.
Furthermore i can visually see the box beeing checked off ,but another field keeps beeing hidden. I have another field that should appear when the checkbox are cheked.
Best regards Mathias
0
Ifra Saqlain
Hi Mathias Katz Sørensen,
Try this code once for -- pseudo code:
Code:
JQuery CDN - add to document_head.hbs file.
And ,also I found this article :
https://support.zendesk.com/hc/en-us/community/posts/4408860835226-Need-help-in-copying-a-ticket-field-s-value-to-another-ticket-field
Thanks
0
Mathias Katz Sørensen
Hi Ifra
So my request, can seem kinda odd, as I easily would be able to tell the end-user to input the string direcly into the description_field, which would in some sense be much easier. However i would like to have the information 2 Places at the same time, as my other configurations are based upon different custom fields.
I've tried something like: client.get('ticket.customField:custom_field_12345678'), but unfortunatly this didnt work for me.
This is an example of what i tried to fix my issue
0
Ifra Saqlain
Hi Mathias Katz Sørensen,
If you want user input then comment this code if exists in your theme or do not use it for your theme if you are going to use it
This code is for hiding the fields from some specific forms after filling those required fields.
You can tell me your query so I can find solution for that :)
Thanks
1
Se connecter pour laisser un commentaire.