Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 2.92 KB

PX1033.md

File metadata and controls

79 lines (61 loc) · 2.92 KB

PX1033

This document describes the PX1033 diagnostic.

Summary

Code Short Description Type Code Fix
PX1033 The DAC does not have an explicit primary key declaration Warning (ISV Level 3: Informational) Available

Diagnostic Description

You can define a primary key field in a DAC. The diagnostic suggests adding a primary key definition to a DAC. The warning is shown only for DACs that have an attribute derived from the PXCacheName attribute, or an attribute derived from the PXPrimaryGraphBase attribute such as PXPrimaryGraphAttribute. The diagnostic does not check abstract DACs and DACs which have only unbound DAC properties (fully-unbound DACs used for custom popups and filters for inquiry forms).

To fix the issue, add the PK class to the DAC.

The code fix generates a primary key and the 'Find' method which allows to easily find DAC row by providing values composing primary key.

Example of Code for Which the Warning Is Shown

[PXCacheName(Messages.SOOrder)]
public class SOOrder : PXBqlTable, IBqlTable
{
	#region OrderType
	public abstract class orderType : PX.Data.BQL.BqlString.Field<orderType> { }

	[PXDBString(2, IsKey = true, IsFixed = true, InputMask = ">aa")]
	...
	public virtual String OrderType {get; set; }
	#endregion
        
        #region OrderNbr
	[PXDBString(IsKey = true, InputMask = "")]
	[PXDefault]
	[PXUIField(DisplayName = "Order Nbr.")]
	public string OrderNbr { get; set; }

	public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr > { }
	#endregion
}

Example of Code Fix

[PXCacheName(Messages.SOOrder)]
public class SOOrder : PXBqlTable, IBqlTable
{
	public class PK : PrimaryKeyOf<SOOrder>.By<orderType, orderNbr>
	{
		public static SOOrder Find(PXGraph graph, string orderType, string orderNbr) => FindBy(graph, orderType, orderNbr);
	}

	#region OrderType
	public abstract class orderType : PX.Data.BQL.BqlString.Field<orderType> { }

	[PXDBString(2, IsKey = true, IsFixed = true, InputMask = ">aa")]
	...
	public virtual String OrderType {get; set; }
	#endregion
        
    #region OrderNbr
	[PXDBString(IsKey = true, InputMask = "")]
	[PXDefault]
	[PXUIField(DisplayName = "Order Nbr.")]
	public string OrderNbr { get; set; }

	public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr > { }
	#endregion
}

Related Articles

Primary Key
To Define a Primary Key
PXCacheNameAttribute Class
PXPrimaryGraphAttribute Class