Acumatica 如何创建具有操作的员工

Acumatica 如何创建具有操作的员工,acumatica,Acumatica,我正在尝试创建一个具有操作的员工 我已确定UI中的最低必填字段为: -员工ID(关键字段) -姓氏(联系DAC) -雇员阶级 -系 我最初尝试输入这些值,只是希望SetValueExt运行默认事件并分配其他请求的字段,但在运行该操作后,我收到了不同的消息,请求这些附加字段。所以我也包括了他们 我的代码如下所示: public PXAction<EPEmployee> testAction; [PXButton] [PXUIField(DisplayNa

我正在尝试创建一个具有操作的员工

我已确定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();}
公共行动测试;
[按钮]
[PXUIField(DisplayName=“EXTENDED”)]
受保护的虚拟IEnumerable测试操作(PXAdapter)
{
EmployeeMaint employeeMaintGraph=PXGraph.CreateInstance();
employeeMaintGraph.Clear();
EPEmployee epEmployeeRow=新的EPEmployee();
epEmployeeRow.AcctCD=“编码”;
epEmployeeRow.AcctName=“employee”;
eEmployeeRow.Status=“A”;
employeeMaintGraph.Employee.Insert(eEmployeeRow);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“EMPDEFAULT”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“EMPDEFAULT”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“ADMIN”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,1);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“employee”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“R”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“M”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“E”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“D”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“M”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“M”);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt(eEmployeeRow,“EP”);
employeeMaintGraph.CurrentEmployee.Update(eEmployeeRow);
联系人行=新联系人();
contactRow.LastName=“LastName”;
employeeMaintGraph.Contact.Insert(contactRow);
地址行=新地址();
addressRow.CountryID=“美国”;
employeeMaintGraph.Address.Insert(addressRow);
employeeMaintGraph.Actions.PressSave();
返回适配器。Get();}
使用此当前版本,我得到以下信息: “错误:“分支”不能为空。错误:“默认位置”不能为空。错误:“路由电子邮件”不能为空。

我在数据库中的BAccount、Employee、Vendor(Employee 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);
}
public-PXAction-CreateEmployee;
[按钮]
[PXUIField(DisplayName=“创建员工”)]
受保护的void createEmployee()
{
EmployeeMaint employeeMaintGraph=PXGraph.CreateInstance();
EPEmployee epEmployeeRow=新的EPEmployee();
epEmployeeRow.acctd=“EMPLOYEE1”;
epEmployeeRow=employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow=employeeMaintGraph.Contact.Current=employeeMaintGraph.Contact.Select();
contactRow.FirstName=“John”;
contactRow.LastName=“绿色”;
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow=employeeMaintGraph.Address.Current=employeeMaintGraph.Address.Select();
addressRow.CountryID=“美国”;
addressRow=employeeMaintGraph.Address.Update(addressRow);
addressRow.State=“DC”;
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID=“EMPSTAND”;
epEmployeeRow.DepartmentID=“财务”;
employeeMaintGraph.Employee.Update(eEmployeeRow);
employeeMaintGraph.Actions.PressSave();
抛出新的PXRedirectRequiredException(employeeMaintGraph,null);
}

谢谢你,罗斯兰。我会给它拍张照片谢谢你@RuslanDev。工作得很好。我看到了我的错误。1跟进问题:是否分配employeeMaintGraph.Contact.Current=employeeMaintGraph.Contact.Select();因为一个特定的原因?调试之后,该数据视图的内容似乎在初始插入之后就已经可用了。我像这样尝试了Contact contactRow=employeeMaintGraph.Contact.Current,似乎在插入新员工时正确保存了记录,
employeeMaintGraph.Contact.Current
将始终返回主联系人记录,因为联系人记录会自动插入缓存,因此通过PXCache/Data View的当前属性可用。
Select()
方法的使用更加通用,因为它可以在所有可能的sce中工作