-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSkipFormValidation_D365F&O
96 lines (78 loc) · 3.43 KB
/
SkipFormValidation_D365F&O
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// <summary>
/// Using OnValidatingField Event handler . How to get the record and how to do validation and how to send validation result. Expand the Table > Events > Right click on OnValidatingField and copy method and paste it inside class.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(VendTable), DataEventType::ValidatingField)]
public static void VendTable_onValidatingField(Common sender, DataEventArgs e)
{
VendTable VendTable = sender as VendTable; // Code to get the buffer
boolean ret = true;
ValidateFieldEventArgs args = e as ValidateFieldEventArgs; // Code to get args
switch (args.parmFieldId())
{
case fieldNum(VendTable, VendorRank):
{
if(VendTable.VendorRank == 10)
{
ret = checkFailed("Rank 10 is worst rank you can get"); // Just a validation to display on user interface
}
}
break;
}
args.parmValidateResult(ret); // Code to send the validation result.**********************@@@@@@*******************************
}
/// <summary>
/// Using OnValidatedField eventhandler . How to get the record and how to do validation and how to send validation result. Expand the Table > Events > Right click on onValidatedField and copy method and paste it inside class.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(VendTable),DataEventType::ValidatedField)]
public static void VendTable_onValidatedField(Common sender, DataEventArgs e)
{
VendTable VendTable = sender as VendTable; // Code to get the buffer
boolean ret = true;
ValidateFieldEventArgs args = e as ValidateFieldEventArgs; // Code to get args
switch (args.parmFieldId())
{
case fieldNum(VendTable, VendorRank):
{
if(VendTable.VendorRank == 20)
{
ret = checkFailed("Rank 20 is worst rank you can get - OnValidated"); // Just a validation to display on user interface
}
}
break;
}
args.parmValidateResult(ret); // Code to send the validation result.
}
/// <summary>
/// This method is for the ValidateField on the Table>Methods. Expand Table > Methods > Right click on ValidateField > COpy event handler for Pre.
/// </summary>
/// <param name="args"></param>
[PreHandlerFor(tableStr(VendTable), tableMethodStr(VendTable, validateField))]
public static void VendTable_Pre_validateField(XppPrePostArgs args)
{
VendTable VendTable = args.getThis(); // Code to get buffer
boolean ret;
if(VendTable.VendorRank == 10)
{
ret = checkFailed("Rank 10 is worst rank you can get - Table Method ValidateField");
}
args.setReturnValue(ret); // Code to send the validation result.
}
/// <summary>
/// This method is for the ValidateWrite on the Table>Methods. Expand Table > Methods > Right click on ValidateWrite > COpy event handler for Pre.
/// </summary>
/// <param name="args"></param>
[PreHandlerFor(tableStr(VendTable), tableMethodStr(VendTable, validateWrite))]
public static void VendTable_Pre_validateWrite(XppPrePostArgs args)
{
VendTable VendTable = args.getThis(); // Code to get buffer
boolean ret;
if(VendTable.VendorRank == 20)
{
ret = checkFailed("Rank 20 is worst rank you can get - Table Method ValidateWrite");
}
args.setReturnValue(ret); // Code to send the validation result.
}