I have a client script and on a button click, a di...
# suitescript
m
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); }); }
a
There's no mechanism in N/dialog for getting a value from custom field you create in the dialog. the only result returned is which button they clicked. by the time the promise resolves your dialog is gone, so your getElementbyId.value is null
👍 1
you probably want to use the N/serverwidget instead to create a form for the user's input
👍 1
... you could also revisit the design and instead of a button and a client script they just edit the record and check an escalation box... when they do that you make the escalation field visible and mandatory?
a
Dialogs are not blocking, your code keep running, you need to build something around it. Me, personally, for anything more than pure information(alerts) I will switch to
sweetalert
, I’m not a big fan of third party libraries but this one has never let me down in 7 years.
j
@alien4u Have you ever used SweetAlert with TypeScript? I'm running into a snag with how to load it inTS because you can't import it like modules (the way you would in the 'define' params in JS)
a
@Jeremy No, never used TypeScript so I can’t tell.
104 Views