Acumatica 从操作中插入客户位置

Acumatica 从操作中插入客户位置,acumatica,Acumatica,我有一个创建新客户位置的操作。 到目前为止,我只是尝试加载带有现有记录的页面 使用此代码,结果是肯定的 公共虚拟IEnumerable NewLocation(PXAdapter) { CustomerLocationMaint locationGraph=PXGraph.CreateInstance(); Location locationRow=新位置(); locationGraph.Location.Current=locationGraph.Location.Search(116,“A

我有一个创建新客户位置的操作。 到目前为止,我只是尝试加载带有现有记录的页面

使用此代码,结果是肯定的

公共虚拟IEnumerable NewLocation(PXAdapter) { CustomerLocationMaint locationGraph=PXGraph.CreateInstance(); Location locationRow=新位置(); locationGraph.Location.Current=locationGraph.Location.Search(116,“ABARTENDE”); locationGraph.Location.Insert(locationRow); 抛出新的PXRedirectRequiredException(locationGraph,null){Mode=PXBaseRedirectException.WindowMode.NewWindow}; 返回适配器Get(); } 但是,此其他版本会加载空白页:

公共虚拟IEnumerable NewLocation(PXAdapter) { CustomerLocationMaint locationGraph=PXGraph.CreateInstance(); Location locationRow=新位置(); locationRow.BAccountID=109;//ABARTENDE locationRow.LocationID=116;//MAIN locationGraph.Location.Insert(locationRow); 抛出新的PXRedirectRequiredException(locationGraph,null){Mode=PXBaseRedirectException.WindowMode.NewWindow}; 返回适配器Get(); } 我需要一个类似于第二个的版本,因为最终,新的LocationCD将从此操作中输入。
有什么想法吗?

在第二个示例中,您试图显式设置LocationID,这是一个需要分配的标识字段。我在源代码中找到了几个示例:

    public PXDBAction<BAccount> addLocation;
    [PXUIField(DisplayName = Messages.AddNewLocation)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
    public virtual void AddLocation()
    {
        var row = BAccount.Current;
        if (row == null || row.BAccountID == null) return;

        LocationMaint graph = null;
        switch (row.Type)
        {
            case BAccountType.VendorType:
                graph = PXGraph.CreateInstance<AP.VendorLocationMaint>();
                break;
            case BAccountType.CustomerType:
                graph = PXGraph.CreateInstance<AR.CustomerLocationMaint>();
                break;
            default:
                graph = PXGraph.CreateInstance<LocationMaint>();
                break;
        }


        var newLocation = (Location)graph.Location.Cache.CreateInstance();
        newLocation.BAccountID = row.BAccountID;
        var locType = LocTypeList.CustomerLoc;
        switch (row.Type)
        {
            case BAccountType.VendorType:
                locType = LocTypeList.VendorLoc;
                break;
            case BAccountType.CombinedType:
                locType = LocTypeList.CombinedLoc;
                break;
        }
        newLocation.LocType = locType;
        graph.Location.Insert(newLocation);
        PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);

    }
公共PXDBAction addLocation;
[PXUIField(DisplayName=Messages.AddNewLocation)]
[PXButton(ImageKey=PX.Web.UI.Sprite.Main.DataEntry)]
公共虚拟void AddLocation()
{
var行=BAccount.Current;
if(row==null | | row.BAccountID==null)返回;
LocationMaint图形=空;
开关(行类型)
{
案例BAccountType.VendorType:
graph=PXGraph.CreateInstance();
打破
案例BAccountType.CustomerType:
graph=PXGraph.CreateInstance();
打破
违约:
graph=PXGraph.CreateInstance();
打破
}
var newLocation=(Location)graph.Location.Cache.CreateInstance();
newLocation.BAccountID=row.BAccountID;
var locType=LocTypeList.CustomerLoc;
开关(行类型)
{
案例BAccountType.VendorType:
locType=LocTypeList.VendorLoc;
打破
案例BAccountType.CombinedType:
locType=LocTypeList.CombinedLoc;
打破
}
newLocation.LocType=LocType;
图.位置.插入(新位置);
pxrirecthelper.TryRedirect(图形,pxrirecthelper.WindowMode.NewWindow);
}
    public virtual IEnumerable NewLocation(PXAdapter adapter)
    {
            CustomerLocationMaint locationGraph = PXGraph.CreateInstance<CustomerLocationMaint>();
            Location locationRow = new Location();
            locationRow.BAccountID = 109; //ABARTENDE
            locationRow.LocationID = 116; //MAIN
            locationGraph.Location.Insert(locationRow);
            throw new PXRedirectRequiredException(locationGraph, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow };
                    return adapter.Get();
    }
    public PXDBAction<BAccount> addLocation;
    [PXUIField(DisplayName = Messages.AddNewLocation)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
    public virtual void AddLocation()
    {
        var row = BAccount.Current;
        if (row == null || row.BAccountID == null) return;

        LocationMaint graph = null;
        switch (row.Type)
        {
            case BAccountType.VendorType:
                graph = PXGraph.CreateInstance<AP.VendorLocationMaint>();
                break;
            case BAccountType.CustomerType:
                graph = PXGraph.CreateInstance<AR.CustomerLocationMaint>();
                break;
            default:
                graph = PXGraph.CreateInstance<LocationMaint>();
                break;
        }


        var newLocation = (Location)graph.Location.Cache.CreateInstance();
        newLocation.BAccountID = row.BAccountID;
        var locType = LocTypeList.CustomerLoc;
        switch (row.Type)
        {
            case BAccountType.VendorType:
                locType = LocTypeList.VendorLoc;
                break;
            case BAccountType.CombinedType:
                locType = LocTypeList.CombinedLoc;
                break;
        }
        newLocation.LocType = locType;
        graph.Location.Insert(newLocation);
        PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);

    }