0
我试图创建一个动作一个雇员。在UI如何建立员工与行动
我已经确定了最低要求的领域: - 雇员(键字段) - 姓氏(联系DAC) - Employee类 - 部门
我最初试图进入这些值只期待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继承它),联系人和地址表中找到了数据库中的Branch字段,但没有运气。 任何想法可能是什么错误?
谢谢。
由于鲁斯兰。我会给它一个镜头 –
谢谢@RuslanDev。工作很好。我看到了我的错误。 1跟进的问题:你分配** employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select(); **为特定的原因是什么? 调试之后,似乎该数据视图的内容在初始插入后已经可用。 我试图像这样**联系contactRow = employeeMaintGraph.Contact.Current **,似乎正确保存记录 –
当插入一个新员工,'employeeMaintGraph.Contact.Current'将始终返回主联系人记录作为接触记录会自动插入缓存,因此可通过PXCache/Data View的Current属性变为可用。 “Select()”方法的使用更通用一些,因为它可以在所有可能的情况下工作,无论您是需要插入新的Employee还是更新现有的Employee。 – RuslanDev