
[英]Acumatica - How to invoke Create Receipt action on a Sales Order (Type RC) programatically
[英]How to create an Employee with an Action
我正在尝试通过操作创建一个Employee。
我已将UI中的最低要求字段标识为:-员工ID(关键字段)-姓氏(联系DAC)-员工类别-部门
我最初尝试输入这些值,只是希望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();}
在当前的最新版本中,我收到消息:“ 错误:'分支'不能为空。错误:'默认位置'不能为空。错误:'路由电子邮件'不能为空。 ”
我在BAccount,Employee,Vendor(雇员DAC继承自该数据库),contact和Address表中寻找数据库中的Branch字段时没有运气。 知道错误可能是什么吗?
谢谢。
请参阅下面的代码片段,以获取在操作中创建Employee的示例:
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.