Hello,
I have a reference group control on a form which is having a lookupreference method on corresponding field in form datasource.
Now i have a another form where i have the same reference group control and i want the same lookupreference method to be used there.
What should i do to avoid writing the same code in the lookupreference method of this new form?
The same reference group control may be used in another forms gets created in future. everytime i don't want to write the same code in lookupreference method on each of those new forms.
Can a Class provide the solution for reuse of the code?
*This post is locked for comments
Thanks Martin.
The solution is simple - extract your code to a separate method (typically placed on the table you're looking up). Your replacementLookup() method will have just a single line - a call to the table method.
Hi Rachit,
I want to use standard framework lookup with a filter on it. Due to this filter, i have to override the lookupreference method and apply that filter in it.
so i want to avoid override this lookupreference method & writing filter code again & again on every new form where i use that reference group control.
Hi VDY,
Adding to Dominic's advise you can find similar example at \Forms\HcmGoal\Data Sources\HcmGoal\Fields\ClosedByManager\Methods\lookupReference().
Regarding your question :"Everytime I don't want to write the same code in lookupreference method on each of those new forms.", if you do not want to use the standard framework lookup which comes on the basis of relations defined on the table then you will need to override the lookupReference method, otherwise you need to rethink about the relations between your table.
Hope that helps.
For lookup method they are usually created at the Table.
Then override the form > datasource > field's lookup method call that lookup method instead.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156