Problem with onFocusGained

Hi All

A small difficulty here. Table A keeps track of donations & table stores details for these donations. A single donation may have more than one detail. When detail is being created, the amount of the donations is stored in a global variable(global.donation_amount). Another global variable(global.don_detail_amt) is also created with a default value of “0”. On the detail form, when tabbing into the detail_amount field a onFocuseGained method is triggered, putting the default value (global.donation_amount) in it.

function set_Detail_Amount() {
	if(globals.don_detail_total_amt < 1){
		detail_amount = globals.don_amount;
	}
	else if(globals.don_detail_total_amt > 0 && globals.don_detail_total_amt < globals.don_amount){
		detail_amount = globals.don_amount - globals.don_detail_total_amt;
	}
	elements.fld_amount.selectAll();
}

The data in the detail_amount field is then changed (if necessary). When tabbing out of the detail_amount field a onFocusLost method is triggered, displaying the appropriate button.

function set_Buttons() {
	globals.don_detail_total_amt = (globals.don_detail_total_amt + detail_amount);
	if(globals.don_detail_total_amt != globals.don_amount){
		elements.btn_do_another_detail.visible = true;
		elements.lbl_do_another_detail.visible = true;
	}
	else{
		elements.btn_done_with_detail.visible = true;
		elements.lbl_done_with_detail.visible = true;
	}
	application.updateUI();
}

This works fine in 3.5.x but in 5.2, although the value in the detail_amount field can be changed, the value that the method sees never changes, ie: if the onFocuseGained method puts a value of 300, and the user changes it to 100, the form shows 100 but the method only sees 300. I observed this by watching the variables in the debug mode.

If I remove the onFocuseGained method then the onFocusLost method works properly. but this removes the important error checking portion of the onFocuseGained method.

I know this is wordy but i don’t know how else to explain it. Thanks for your assistance.

can you make a sample solution for this and attach it to a case?
This can be pretty tricky.

Focus events are not really there for datachanges (thats why we have ondatachange)

Hi Johan

Focus events are not really there for datachanges (thats why we have ondatachange)

This is true. In this case the data needs to be changed about 10% of the time. Thus the need for the onFocusLost trigger. One of the test was to take the onFocusGained method and trigger it with a onDataChage event earlier on the form. The results was the same.

Case submitted. #313408

After some further testing I found a workaround by adding an invisible field and switching the onFocusLost method to onFocusGained of the invisible field.