Event Listener

28 views
Skip to first unread message

Kim Sokil

unread,
Mar 17, 2017, 11:19:40 AM3/17/17
to ParaSQL Support
There lots of times that when a user enters a value in a field - another field should update.  It's not an if-then-else situation.
If I am understanding correctly a change value event listener could work.  This is where my programming skills are limited.
Can you give me a sample of what the event coding would look like for this scenario:

If a user enters a date in the field Termination_Date (changes from null), change the Current_Status to 'Terminated'.

I am going to assume that the event listener would be on Termination_Date?

Thanks
Kim

Robert Dyas

unread,
Mar 17, 2017, 5:27:56 PM3/17/17
to ParaSQL Support
Yes, put an event listener on the Termination_Date field. The Event Type should be change so you only capture a change.
The function for the event listener would look something like this:

function (event) {

var terminationDateField = event.target; // event.target is equal to the widget that fired the event

if (terminationDateField.getDataValue().isNotNull()) {

var currentStatusField = parasql.app.getWidgetById('ID1017'); // current status field
currentStatusField.getDataValue().setString('Terminated');
currentStatusField.redisplay(); // Terminated won't show immediately in the UI unless you do this

}

}

Kim Sokil

unread,
Mar 20, 2017, 3:54:44 PM3/20/17
to ParaSQL Support
worked like a charm!
Reply all
Reply to author
Forward
0 new messages