Specified Cast is not Valid in new Master Screen of Acumatica ERP System

跟風遠走 提交于 2019-12-25 02:35:11

问题


I already create new additional master screen (ListView) in Acumatica. The following code is the source code of the page :

<%@ Page Language="C#" MasterPageFile="~/MasterPages/ListView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="CS213000.aspx.cs" Inherits="Page__213000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/ListView.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" PrimaryView="RoomMaster" SuspendUnloading="False" TypeName="SGLCustomizeProject.RoomMaint" >
</px:PXDataSource>
</asp:Content>

<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
<px:PXGrid ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100"
    AllowPaging="True" AllowSearch="True" AdjustPageSize="Auto" DataSourceID="ds" SkinID="Inquire" TabIndex="900" 
    AllowAdd="True" TemporaryFilterCaption="Filter Applied">
<Levels>
<px:PXGridLevel DataMember="RoomMaster">
<Columns>
<px:PXGridColumn DataField="BranchID" Width="120px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="BuildingID">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="RoomCD" Width="200px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="RoomDescription" Width="200px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="Status">
                </px:PXGridColumn>
</Columns>
        </px:PXGridLevel>
    </Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="200" />
</px:PXGrid>

The following code is the source code of PXGraph :

using System;
using System.Collections;
using System.Collections.Generic;
using PX.SM;
using PX.Data;
namespace SGLCustomizeProject
{
    public class RoomMaint : PXGraph<RoomMaint>
    {
        public PXCancel<RoomMaster> Cancel;
        public PXSave<RoomMaster> Save;
        public PXInsert<RoomMaster> Insert;
        public PXSelect<RoomMaster> RoomMaster;
    }
}

The following code is the source code of DAC :

namespace SGLCustomizeProject
{
using System;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.Objects.FA;

[System.SerializableAttribute()]
public class RoomMaster : PX.Data.IBqlTable
{
    #region BranchID
    public abstract class branchID : PX.Data.IBqlField
    {
    }
    protected Int32? _BranchID;
    [PXDBInt(IsKey = true)]
    [PXDefault()]
    //[PXUIField(DisplayName = "BranchID")]
    [Branch()]
    public virtual Int32? BranchID
    {
        get
        {
            return this._BranchID;
        }
        set
        {
            this._BranchID = value;
        }
    }
    #endregion

    #region BuildingID
    public abstract class buildingID : PX.Data.IBqlField
    {
    }
    protected Int32? _BuildingID;
    [PXDBInt()]
    [PXDefault()]
    [PXSelector(typeof(Search<Building.buildingID, 
                        Where<Building.branchID, 
                         Equal<Current<FALocationHistory.locationID>>>>),
        SubstituteKey = typeof(Building.buildingCD), DescriptionField = typeof(Building.description))]
    [PXUIField(DisplayName = "Building")]
    public virtual Int32? BuildingID
    {
        get
        {
            return this._BuildingID;
        }
        set
        {
            this._BuildingID = value;
        }
    }
    #endregion

    #region RoomCD
    public abstract class roomCD : PX.Data.IBqlField
    {
    }
    protected string _RoomCD;
    [PXDBString(50, IsUnicode = true, IsKey = true)]
    [PXDefault()]
    [PXUIField(DisplayName = "Kode Area")]
    public virtual string RoomCD
    {
        get
        {
            return this._RoomCD;
        }
        set
        {
            this._RoomCD = value;
        }
    }
    #endregion

    #region RoomID
    public abstract class roomID : PX.Data.IBqlField
    {
    }
    protected int? _RoomID;
    [PXDBIdentity()]
    [PXUIField(Enabled = false)]
    public virtual int? RoomID
    {
        get
        {
            return this._RoomID;
        }
        set
        {
            this._RoomID = value;
        }
    }
    #endregion

    #region RoomDescription
    public abstract class roomDescription : PX.Data.IBqlField
    {
    }
    protected string _RoomDescription;
    [PXDBString(75, IsUnicode = true)]
    [PXUIField(DisplayName = "Deskripsi Area")]
    public virtual string RoomDescription
    {
        get
        {
            return this._RoomDescription;
        }
        set
        {
            this._RoomDescription = value;
        }
    }
    #endregion

    #region Status
    public abstract class status : PX.Data.IBqlField
    {
    }
    protected string _Status;
    [PXDBString(2, IsFixed = true)]
    [PXDefault()]
    [PXUIField(DisplayName = "Status")]
    [PXStringList(new string[]
        {
            "01",
            "02"
        },

        new string[]
        {
            "Active",
            "Inactive"
        })]
    public virtual string Status
    {
        get
        {
            return this._Status;
        }
        set
        {
            this._Status = value;
        }
    }
    #endregion

    #region tstamp
    public abstract class Tstamp : PX.Data.IBqlField
    {
    }
    protected byte[] _tstamp;
    [PXDBTimestamp()]
    public virtual byte[] tstamp
    {
        get
        {
            return this._tstamp;
        }
        set
        {
            this._tstamp = value;
        }
    }
    #endregion

    #region CreatedByID
    public abstract class createdByID : PX.Data.IBqlField
    {
    }
    protected Guid? _CreatedByID;
    //[PXDBField()]
    //[PXDefault()]
    //[PXUIField(DisplayName = "CreatedByID")]
    [PXDBCreatedByID]
    public virtual Guid? CreatedByID
    {
        get
        {
            return this._CreatedByID;
        }
        set
        {
            this._CreatedByID = value;
        }
    }
    #endregion

    #region CreatedByScreenID
    public abstract class createdByScreenID : PX.Data.IBqlField
    {
    }
    protected string _CreatedByScreenID;
    //[PXDBString(8, IsFixed = true)]
    //[PXDefault("")]
    //[PXUIField(DisplayName = "CreatedByScreenID")]
    [PXDBCreatedByScreenID]
    public virtual string CreatedByScreenID
    {
        get
        {
            return this._CreatedByScreenID;
        }
        set
        {
            this._CreatedByScreenID = value;
        }
    }
    #endregion

    #region CreatedDateTime
    public abstract class createdDateTime : PX.Data.IBqlField
    {
    }
    protected DateTime? _CreatedDateTime;
    //[PXDBDate()]
    //[PXDefault(TypeCode.DateTime, "01/01/1900")]
    //[PXUIField(DisplayName = "CreatedDateTime")]
    [PXDBCreatedDateTime]
    public virtual DateTime? CreatedDateTime
    {
        get
        {
            return this._CreatedDateTime;
        }
        set
        {
            this._CreatedDateTime = value;
        }
    }
    #endregion

    #region LastModifiedByID
    public abstract class lastModifiedByID : PX.Data.IBqlField
    {
    }
    protected Guid? _LastModifiedByID;
    //[PXDBField()]
    //[PXDefault()]
    //[PXUIField(DisplayName = "LastModifiedByID")]
    [PXDBLastModifiedByID]
    public virtual Guid? LastModifiedByID
    {
        get
        {
            return this._LastModifiedByID;
        }
        set
        {
            this._LastModifiedByID = value;
        }
    }
    #endregion

    #region LastModifiedDateTime
    public abstract class lastModifiedDateTime : PX.Data.IBqlField
    {
    }
    protected DateTime? _LastModifiedDateTime;
    //[PXDBDate()]
    //[PXDefault(TypeCode.DateTime, "01/01/1900")]
    //[PXUIField(DisplayName = "LastModifiedDateTime")]
    [PXDBLastModifiedDateTime]
    public virtual DateTime? LastModifiedDateTime
    {
        get
        {
            return this._LastModifiedDateTime;
        }
        set
        {
            this._LastModifiedDateTime = value;
        }
    }
    #endregion
}
}

When I tried to add new record for the first time is doesn't matter, but when I tried to add another record or open the screen, I got the following error message :

Does anyone know how to solve this case ? Thanks


回答1:


The PXSelector on BuildingID field shows a WHERE clause limiting results to Current FALocationHistory.locationID but I don't see FALocationHistory in the context of the RoomMaint graph. Did you intend to limit the list based on the choice of BranchID in this new RoomMaster row? If true, then you will also need CommitChanges=true on the BranchID column and also AutoRefresh=true on the BuildingID px:PXSelector control in a RowTemplate section of the gridlevel, such as:

<RowTemplate>

<px:PXSelector ID="edBuildingID" runat="server" DataField="BuildingID" 
                    DataSourceID="ds" AutoRefresh="True">

</RowTemplate>

You may need to add SyncPosition=true on the Grid tag of the markup in this case. Also try placing the IsKey=true only on the RoomID identity field instead of BranchID/RoomCD.



来源:https://stackoverflow.com/questions/57519737/specified-cast-is-not-valid-in-new-master-screen-of-acumatica-erp-system

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!