Skip to content

Latest commit

 

History

History
84 lines (64 loc) · 3.26 KB

PX1030.md

File metadata and controls

84 lines (64 loc) · 3.26 KB

PX1030

This document describes the PX1030 diagnostic.

Summary

Code Short Description Type Code Fix
PX1030 The PXDefault attribute of the field is used incorrectly. Warning (ISV Level 1: Significant) or Error Available

Diagnostic Description

For the information on how to use the PXDefault attribute correctly, see Default Values.

If the PXDefault attribute is used without the PersistingCheck property set to Nothing, the attribute used on a custom field defined in PXCacheExtension can prevent persisting of records to the database.

If a DAC or DAC extension includes an unbound field with the PXDefault attribute that doesn't have PersistingCheck = PXPersistingCheck.Nothing, an error is displayed. For this error, you can select one of the following two code fixes:

  • A code fix that changes the PXDefault attribute to PXUnboundDefault
  • A code fix that adds PersistingCheck = PXPersistingCheck.Nothing to the PXDefault attribute

If a DAC extension includes a bound field with the PXDefault attribute that doesn't have PersistingCheck = PXPersistingCheck.Nothing, a warning is displayed. For this warning, the code fix adds PersistingCheck = PXPersistingCheck.Nothing to the PXDefault attribute.

The diagnostic is not displayed for the fields of the DACs that contain only unbound fields (such as the DACs for filters on inquiry or processing forms).

Example of Code that Results in the Error and Warning

public class CAAdjExtension : PXCacheExtension<CAAdj>
{
    #region UsrCADocLineCntr
    public abstract class usrCADocLineCntr : IBqlField
    {
    }

    [PXDBInt]
    [PXDefault(0)] // The PX1030 warning is displayed for this line.
    public virtual int? UsrCADocLineCntr { get; set; }
    #endregion

    #region Selected
    public abstract class selected : PX.Data.IBqlField
    {
    }
    
    [PXBool]
    [PXDefault(false)] // The PX1030 error is displayed for this line.
    [PXUIField(DisplayName = "Selected")]
    public virtual bool? Selected { get; set; }
    #endregion
}

Example of Code Fix

public class CAAdjExtension : PXCacheExtension<CAAdj>
{
    #region UsrCADocLineCntr
    public abstract class usrCADocLineCntr : IBqlField
    {
    }

    [PXDBInt]
    [PXDefault(0, PersistingCheck = PXPersistingCheck.Nothing)]
    public virtual int? UsrCADocLineCntr { get; set; }
    #endregion

    #region Selected
    public abstract class selected : PX.Data.IBqlField
    {
    }

    [PXBool]
    [PXUnboundDefault] //First code fix option
    //[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)] is another code fix option.
    [PXUIField(DisplayName = "Selected")]
    public virtual bool? Selected { get; set; }
    #endregion
}

Related Articles