Hi @Max,
I’ve now found a solution because your instructions above didn’t work for me, it only worked with the ID [total]. But whatever. Now I have it.
function formatDateTime() {
const now = new Date();
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = String(now.getFullYear()).slice(-2);
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const lValue = `[${day}${month}${year}|${hours}${minutes}]`;
//const aValue = `A-${day}${month}${year}|${hours}${minutes}`;
//const tValue = `T-${day}${month}${year}|${hours}${minutes}`;
return {lValue, aValue, tValue};
}
const {lValue, aValue, tValue} = formatDateTime();
widget.setFieldValue('[ticket-id]', lValue);
widget.setFieldValue('[current-date-a]', aValue);
widget.setFieldValue('[current-date-t]', tValue);
async function setClientIP() {
try {
// Collect the client's public IP address
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
// Insert IP address into the variable
const clientIP = data.ip;
// Put the IP address in the widget field
widget.setFieldValue('[client-ip]', `IP: ${clientIP}`);
} catch (error) {
console.error('Error getting IP address:', error);
}
}
// Funktion aufrufen
setClientIP();
Additionally two hidden fields with the ID
Now I have createt a Ticket ID:
We had already discussed the issue of the IP address here with Helga
IP Address for Contact Form