-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCreateLookupFormDataSourceFieldD365FO.xpp
70 lines (54 loc) · 2.41 KB
/
CreateLookupFormDataSourceFieldD365FO.xpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//Author Mafigu Huggins
//Tel: +263 782 326 160
//Email: mafiguhuggins@gmail.com
//In this file, there are two classes and two clicked() methods code. Please see the video or article to understand
//In this class, the methods are overriden
class Moeen_LookupFormMethodOverrides
{
protected void new()
{
}
public static Moeen_LookupFormMethodOverrides construct()
{
//Returns the object of Moeen_LookupFormMethodOverrides class
return new Moeen_LookupFormMethodOverrides();
}
public void PersonnelNumber_OnLookup(FormStringControl _callingControl)
{
//Creating lookup here
//Lookup will show the PersonnelNumber from HcmWorker table.
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmWorker), _callingControl);
sysTableLookup.addLookupfield(fieldNum(HcmWorker, PersonnelNumber));
sysTableLookup.performFormLookup();
}
}
//In this class, event is handled and registration of method is done.
//Event handler class
class Moeen_LookupFormEventHandler
{
//Go to the form -> data source -> YOUR DATA SOURCE -> Events -> OnInitialized
//Right click the OnInitialized and Copy the event handler
//Paste it Here
[FormDataSourceEventHandler(formDataSourceStr(Moeen_LookupForm, Moeen_LookupTable), FormDataSourceEventType::Initialized)]
public static void Moeen_LookupTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
//Call the construct method of Moeen_LookupFormMethodOverrides class and get the object of it.
//Stores the object in overrides variable
var overrides = Moeen_LookupFormMethodOverrides::construct();
//Registering to the methods in Moeen_LookupFormMethodOverrides
//Passing the customized Moeen_LookupTable table and it's PersonnelNumber
sender.object(fieldNum(Moeen_LookupTable, PersonnelNumber)).registerOverrideMethod(methodStr(FormDataObject, lookup),
methodStr(Moeen_LookupFormMethodOverrides, PersonnelNumber_OnLookup), overrides);
}
}
//Clicked methods logic
//Clicked method of OK Button
//super();
info(strFmt("%1", Moeen_LookupTable_PersonnelNumber.valueStr()));
Moeen_LookupTable lookupTable;
lookupTable.PersonnelNumber = Moeen_LookupTable_PersonnelNumber.valueStr();
lookupTable.insert();
element.close();
//Clicked method of Cancel Button
//super();
element.close();