Skip to content

Latest commit

 

History

History
68 lines (58 loc) · 2.27 KB

PX1055.md

File metadata and controls

68 lines (58 loc) · 2.27 KB

PX1055

This document describes the PX1055 diagnostic.

Summary

Code Short Description Type Code Fix
PX1055 An invalid primary key of the DAC is used. Error Available

Diagnostic Description

The key fields of a DAC can be defined based on the following guidelines:

  • A field bound to an identity column (that is, a field that has the PXDBIdentity or PXDBLongIdentity attribute) can be the only key field in the DAC.
  • A DAC can have one key field or multiple key fields if none of these key fields is bound to an identity column.

The code fix can do one of the following:

  • Make the field bound to the identity column be the only key field in the DAC
  • Make the field bound to the identity column be a non-key field, and leave all other fields untouched
  • Remove the PXDBIdentity or PXDBLongIdentity attribute from the field and leave all other fields untouched

Example of Incorrect Code

public class FinCategory : PX.Data.IBqlTable
{
    #region CategoryID
    public abstract class categoryID : PX.Data.IBqlField
    {
    }
    [PXDBIdentity(IsKey = true)] //The PX1055 error is displayed for this line.
    [PXUIField(DisplayName = "Category ID")]
    public virtual int? CategoryID { get; set; }
    #endregion
    #region CategoryCD
    public abstract class categoryCD : PX.Data.IBqlField
    {
    }
    [PXDBString(10, IsKey = true, IsUnicode = true)] //The PX1055 error is displayed for this line.
    [PXUIField(DisplayName = "Category ID")]
    public virtual string CategoryCD { get; set; }
    #endregion    
}

Example of Code Fix

public class FinCategory : PX.Data.IBqlTable
{
    #region CategoryID
    public abstract class categoryID : PX.Data.IBqlField
    {
    }
    [PXDBIdentity(IsKey = true)] //This field is the only key field now.
    [PXUIField(DisplayName = "Category ID")]
    public virtual int? CategoryID { get; set; }
    #endregion
    #region CategoryCD
    public abstract class categoryCD : PX.Data.IBqlField
    {
    }
    [PXDBString(10, IsUnicode = true)] //IsKey=true has been removed.
    [PXUIField(DisplayName = "Category ID")]
    public virtual string CategoryCD { get; set; }
    #endregion    
}