Announcements
hi all,
i am having formA and form B (both custom forms.) Form A contains Table A, TableB(header n line). Form B contains Table B only(a dialog form).
when i click on new button(its a menu item button) from Form A it opens FormB. when i create the record in the dialog form, when i click on Ok button. i need to refresh the Table B of formA.
i hav written the below code in Form B and called it in OK button of Form B. its refreshing the table A instead of Table B. any suggestions pls..
private void CallerFOrmDS_Refresh()
{
Object calleform;
FormDataSource fds;
calleform = element.args().caller();
fds = element.args().record().datasource();
if(calleform)
{
fds.refresh();
fds.research(true);
}
}
Hi TestBot,
In case if you still need to use data source A as caller datasource and form A is your form, you can add interface IFormRefreshable to your form and implement method callerRefresh on the form, where you can define refresh logic. When the dialog is closed you can call callerRefresh method from this form.
//Form [Form] public class MyForm extends FormRun implements IFormRefreshable .... public void callerRefresh() { Table2_DS.research(); //or executeQuery } ... //Dialog close action IFormRefreshable callerform = element.args().caller() as IFormRefreshable; if (callingForm != null) { callingForm.callerRefresh(); }
If element.args().record() is a record of Table A, it means that the data source used for the menu item button is Table A. Change its Data Source property to Table B.
By the way, let me improve your code a bit:
private void CallerFOrmDS_Refresh() { FormDataSource fds = FormDataUtil::getFormDataSource(element.args().record()); if (fds) { fds.research(true); } }
Next time, use Insert > Insert Code (in the rich formatting view) to paste source code, as I did.
In form A you can decide which data source you assign with the button. This can be set in the Data source property of the menu item (or the button group where the button is). So, if you set Table B as data source for your button, then your code will refresh data source for Table B.
There's also a property in the button to auto refresh data source, it works in many scenarios. Then you would not have to write any code.
André Arnaud de Cal...
294,127
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator