Problem clearing field in onchange client script (service portal friendly); and check if val is a number

 this approach seemed to work...where the onchange is fired on a field entitled costs_purchase_order and this itself needs to clear if not a number...

function onChange(control, oldValue, newValue, isLoading) { if (isLoading) { return; }
g_form.setMandatory('procontract_ref', false); if (newValue == '') { g_form.clearValue('costs_purchase_order'); return; } if (isNaN(newValue)) { var sMsg = "Please enter the cost as a number"; g_form.clearValue('costs_purchase_order'); try { if (typeof spModal != 'undefined') { spModal.alert(sMsg); } else { var gm = new GlideModal(); gm.setTitle("Warning"); gm.renderWithContent(sMsg); bAttachMissing = true; } } catch (ex) { alert('MTH Check Cost: Error::' + ex); } } else { var sNumVal = parseInt(newValue); if (sNumVal >= 10000) { g_form.setMandatory('procontract_ref', true); } } }


Popular posts from this blog

GlideRecord setValue

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy