如何创建具有操作的员工
How to create an Employee with an Action
我正在尝试创建一个带有操作的员工。
我已将 UI 中的最少必填字段确定为:
- EmployeeID(关键字段)
- 姓氏(联系 DAC)
- 员工 class
- 部门
我最初尝试输入这些值只是希望 SetValueExt 会 运行 默认事件并分配其他请求的字段,但是在 运行 执行该操作后我收到了不同的请求这些附加字段的消息。所以我也包括了它们。
我的代码如下所示:
public PXAction<EPEmployee> testAction;
[PXButton]
[PXUIField(DisplayName = "EXTENDED")]
protected virtual IEnumerable TestAction(PXAdapter adapter)
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
employeeMaintGraph.Clear();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "CODED";
epEmployeeRow.AcctName = "employee";
epEmployeeRow.Status = "A";
employeeMaintGraph.Employee.Insert(epEmployeeRow);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendorClassID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.classID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.departmentID>(epEmployeeRow, "ADMIN");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.positionLineCntr>(epEmployeeRow, 1);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.consolidateToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideCury>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideRate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.payToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.acctName>(epEmployeeRow, "employee");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendor1099>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxAgency>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.updClosedTaxPeriods>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportRounding>(epEmployeeRow, "R");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxUseVendorCurPrecision>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportFinPeriod>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxPeriodType>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.enableTaxStartDate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.landedCostVendor>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.isLaborUnion>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.lineDiscountTarget>(epEmployeeRow, "E");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.ignoreConfiguredDiscounts>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATReversalMethod>(epEmployeeRow, "D");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATInputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATOutputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.type>(epEmployeeRow, "EP");
employeeMaintGraph.CurrentEmployee.Update(epEmployeeRow);
Contact contactRow = new Contact();
contactRow.LastName = "lastname";
employeeMaintGraph.Contact.Insert(contactRow);
Address addressRow = new Address();
addressRow.CountryID = "US";
employeeMaintGraph.Address.Insert(addressRow);
employeeMaintGraph.Actions.PressSave();
return adapter.Get();}
对于当前版本,我收到消息:
“错误:'Branch' 不能为空。错误:'Default Location' 不能为空。错误:'Route Emails' 不能为空。”
我在 BAccount、Employee、Vendor(员工 DAC 从中继承)、contact 和 Address 表中查找了 Branch 字段,但没有成功。
知道错误可能是什么吗?
谢谢。
请参阅下面的代码片段以获取在操作中创建员工的示例:
public PXAction<EPEmployee> CreateEmployee;
[PXButton]
[PXUIField(DisplayName = "Create Employee")]
protected void createEmployee()
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "EMPLOYEE1";
epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
contactRow.FirstName = "John";
contactRow.LastName = "Green";
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
addressRow.CountryID = "US";
addressRow = employeeMaintGraph.Address.Update(addressRow);
addressRow.State = "DC";
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID = "EMPSTAND";
epEmployeeRow.DepartmentID = "FINANCE";
employeeMaintGraph.Employee.Update(epEmployeeRow);
employeeMaintGraph.Actions.PressSave();
throw new PXRedirectRequiredException(employeeMaintGraph, null);
}
我正在尝试创建一个带有操作的员工。
我已将 UI 中的最少必填字段确定为: - EmployeeID(关键字段) - 姓氏(联系 DAC) - 员工 class - 部门
我最初尝试输入这些值只是希望 SetValueExt 会 运行 默认事件并分配其他请求的字段,但是在 运行 执行该操作后我收到了不同的请求这些附加字段的消息。所以我也包括了它们。
我的代码如下所示:
public PXAction<EPEmployee> testAction;
[PXButton]
[PXUIField(DisplayName = "EXTENDED")]
protected virtual IEnumerable TestAction(PXAdapter adapter)
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
employeeMaintGraph.Clear();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "CODED";
epEmployeeRow.AcctName = "employee";
epEmployeeRow.Status = "A";
employeeMaintGraph.Employee.Insert(epEmployeeRow);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendorClassID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.classID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.departmentID>(epEmployeeRow, "ADMIN");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.positionLineCntr>(epEmployeeRow, 1);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.consolidateToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideCury>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideRate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.payToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.acctName>(epEmployeeRow, "employee");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendor1099>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxAgency>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.updClosedTaxPeriods>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportRounding>(epEmployeeRow, "R");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxUseVendorCurPrecision>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportFinPeriod>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxPeriodType>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.enableTaxStartDate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.landedCostVendor>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.isLaborUnion>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.lineDiscountTarget>(epEmployeeRow, "E");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.ignoreConfiguredDiscounts>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATReversalMethod>(epEmployeeRow, "D");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATInputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATOutputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.type>(epEmployeeRow, "EP");
employeeMaintGraph.CurrentEmployee.Update(epEmployeeRow);
Contact contactRow = new Contact();
contactRow.LastName = "lastname";
employeeMaintGraph.Contact.Insert(contactRow);
Address addressRow = new Address();
addressRow.CountryID = "US";
employeeMaintGraph.Address.Insert(addressRow);
employeeMaintGraph.Actions.PressSave();
return adapter.Get();}
对于当前版本,我收到消息: “错误:'Branch' 不能为空。错误:'Default Location' 不能为空。错误:'Route Emails' 不能为空。”
我在 BAccount、Employee、Vendor(员工 DAC 从中继承)、contact 和 Address 表中查找了 Branch 字段,但没有成功。 知道错误可能是什么吗?
谢谢。
请参阅下面的代码片段以获取在操作中创建员工的示例:
public PXAction<EPEmployee> CreateEmployee;
[PXButton]
[PXUIField(DisplayName = "Create Employee")]
protected void createEmployee()
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "EMPLOYEE1";
epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
contactRow.FirstName = "John";
contactRow.LastName = "Green";
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
addressRow.CountryID = "US";
addressRow = employeeMaintGraph.Address.Update(addressRow);
addressRow.State = "DC";
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID = "EMPSTAND";
epEmployeeRow.DepartmentID = "FINANCE";
employeeMaintGraph.Employee.Update(epEmployeeRow);
employeeMaintGraph.Actions.PressSave();
throw new PXRedirectRequiredException(employeeMaintGraph, null);
}