I have a client script and on a button click, a dialog pops up. I need to take the user's input value but globalEscalationReason is showing me null and the script stops processing.
function openPopup() {
const dialogContent = '<div id="customDialog">' +
'<label for="escalationReason">Escalation Reason:</label>' +
'<input type="text" id="escalationReason" name="escalationReason" />' +
'</div>';
const dialogOptions = {
title: 'Escalation Reason',
message: dialogContent,
buttons: [
{label: 'OK', value: 'ok'},
{label: 'Cancel', value: 'cancel'}
]
};
dialog.create(dialogOptions)
.then(function (result) {
if (result === 'ok') {
const globalEscalationReason = document.getElementById('escalationReason').value;
log.debug('Escalation Reason:', globalEscalationReason);
createNoteOnOpportunity('17240693', globalEscalationReason);
} else {
log.debug('Dialog canceled');
}
})
.catch(function (error) {
log.error('Dialog error', error);
});
}