HI,
Below are the sample codes to call the methods of X++ in C# from EP development,
//calling the modified method of the control in EP
public void getstartdate(object sender, EventArgs e)
{
string sdateAx;
sdateAx = (string)this.AxDataSource1.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call(“modified”); }
This method should be written under particular field in Data set in AOT. For that field only we need to assign this method in C# control. And put ‘Autopostback’ TRUE.
call this method on C# control : Onlookup = “getstartdate”.
//Calling static methods.
We can call the static methods in C# which are written at Table or at Class level only.
In below example, we are calling a static method which is written in table ‘Mzk_LeaveHistory’ table and the method name in ‘currentEmployeeId’. And we are catching the value which the method is returning for the validations in C#. Since we can’t do validations by using the code in X++.
Here, based on the login employee we need to validate the leave balance and validation.
public void LeaveBalanceValidation(object sender, AxBoundFieldDataChangedEventArgs e)
{
Int64 EmplId = (Int64)AxSession.AxaptaAdapter.CallStaticRecordMethod(“Mzk_LeaveHistory”, “currentEmployeeId”);
//Response.Write(EmplId);
string LeavetypeBalance = Convert.ToString(e.Value);
//string Leavetypevalidate = Convert.ToString(DropDownList)e.BoundControl).SelectedValue);
string Leavetypevalidate = Convert.ToString(e.Value);
this.LeaveValidation(Leavetypevalidate, EmplId);
this.LeaveBalance(LeavetypeBalance, EmplId);
// this.AxDataSource1.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call(“modified”);
}
Need to call in controller in C# : OnDataChanged = “LeaveBalanceValidation”
Leave Balance can come on the leave type they selected, we are calling a static method in the table by passing the employee id and leave type selected.
For more description, plebe fallow below link: