Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 4.91 KB

File metadata and controls

100 lines (74 loc) · 4.91 KB

PX1110

This document describes the PX1110 diagnostic.

Summary

Code Short Description Type Code Fix
PX1110 The DAC has a DAC field with the PXDBLocalizableString attribute. Therefore, this DAC must declare a NoteID DAC field. Error Available

Diagnostic Description

Data Access Classes (DACs) that contain fields with the PXDBLocalizableString attribute must declare a NoteID field. The NoteID field is required for the Acumatica localization framework to properly store and manage localized field values in the database.

The PXDBLocalizableString attribute is used to mark DAC fields that should support multiple language translations. When such fields are present in a DAC, Acumatica Framework uses the NoteID field as a reference key to link the localized text values stored in the system database tables.

The PX1110 diagnostic detects DACs that:

  • Have at least one field with the PXDBLocalizableString attribute
  • Do not have a NoteID field declared in the DAC and its base DACs

Exceptions when NoteID Field is Not Required

There are some exceptions to the PX1110 diagnostic when a DAC does not require to support localization. The diagnostic will not be triggered in the following cases:

  • The DAC has the PXAccumulator attribute or an attribute derived from the PXAccumulator attribute. Such DACs are used for special accumulation scenarios and do not support localization.
  • The DAC is fully unbound from the database (a virtual DAC). Such DACs do not interact with the database directly and do not require localization support. Since Acuminator does not access the database, it determines whether a DAC is fully unbound based on the following rules:
    • A DAC without any DAC fields or with only unbound DAC fields is considered fully unbound.
    • A DAC marked with PX.Data.PXVirtualAttribute is always considered fully unbound even if it has DB bound fields.
    • A DAC marked with PX.Data.PXProjectionAttribute, PX.Data.PXAccumulatorAttribute or any other attribute derived from PX.Data.PXDBInterceptorAttribute is always considered DB bound even if it has only unbound fields.
    • A DAC with a DB bound NoteID field is considered fully unbound if NoteID is the only DB bound field in the DAC and all other fields in the DAC are unbound.

Code Fix Behavior

The PX1110 code fix automatically adds the missing NoteID field to the DAC with the following characteristics:

  • The NoteID field is added at the end of the DAC field declaration.
  • Appropriate using directives (System and PX.Data.BQL) are automatically added if needed.
  • The field is properly wrapped in the #region NoteID / #endregion block for consistency.

Example of Incorrect Code

[PXCacheName("Some DAC")]
public class SomeDac : PXBqlTable, IBqlTable
{
	#region DacId
	public abstract class dacId : PX.Data.BQL.BqlInt.Field<dacId> { }
	
	[PXDBIdentity(IsKey = true)]
	public virtual int? DacId { get; set; }
	#endregion

	#region Description
	public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
	
	[PXDBLocalizableString(512, IsUnicode = true)]
	public virtual string? Description { get; set; }
	#endregion

	// Missing NoteID field - required because Description has PXDBLocalizableString attribute
}

Example of Code Fix

[PXCacheName("Some DAC")]
public class SomeDac : PXBqlTable, IBqlTable
{
	#region DacId
	[PXDBIdentity(IsKey = true)]
	public virtual int? DacId { get; set; }
	public abstract class dacId : PX.Data.BQL.BqlInt.Field<dacId> { }
	#endregion

	#region Description
	public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
	
	[PXDBLocalizableString(512, IsUnicode = true)]
	public virtual string? Description { get; set; }
	#endregion

	#region NoteID
	public abstract class noteID : BqlGuid.Field<noteID> { }

	[PXNote]
	public virtual Guid? NoteID { get; set; }
	#endregion
}

Related Articles