在AP301000账单与调整界面添加自定义字段引发空对象值错误
Hey there, sorry to hear you're hitting an unexpected error adding those 4 user fields to the AP301000 Bills and Adjustments screen's Details tab—especially since you've pulled this off successfully before. Let's walk through the most likely culprits and fixes, starting with your DAC extension code (which looks structurally solid, by the way):
[PXCacheName("AP Tran Extension")] public class APTranExt : PXCacheExtension<APTran> { #region UsrACAllocModule [PXDBString(30, IsUnicode = true, InputMask = "")] [PXUIField(DisplayName = "Allocation Module")] public virtual string UsrACAllocModule { get; set; } public abstract class usrACAllocModule : PX.Data.BQL.BqlString.Field<usrACAllocModule> { } #endregion #region UsrACAllocBatch [PXDBString(30, IsUnicode = true, InputMask = "")] [PXUIField(DisplayName = "Allocation Batch")] public virtual string UsrACAllocBatch { get; set; } public abstract class usrACAllocBatch : PX.Data.BQL.BqlString.Field<usrACAllocBatch> { } #endregion #region UsrACAllocLineNbr [PXDBInt()] [PXUIField(DisplayName = "Allocation LineNbr")] public virtual int? UsrACAllocLineNbr { get; set; } public abstract class usrACAllocLineNbr : PX.Data.BQL.BqlInt.Field<usrACAllocLineNbr> { } #endregion #region UsrACAllocationID [PXDBString(30, IsUnicode = true, InputMask = "")] [PXUIField(DisplayName = "Allocation ID")] public virtual string UsrACAllocationID { get; set; } public abstract class usrACAllocationID : PX.Data.BQL.BqlString.Field<usrACAllocationID> { } #endregion }
Common Causes & Fixes
1. Stale Cache or Compilation Glitches
Acumatica often holds onto old cache data that clashes with new customizations, even if your code is perfect. Try these steps first:
- Head to System > Management > Cache Management and clear all caches (prioritize the
APTrancache if you can target it specifically). - Republish your customization project, making sure there are no red compilation errors in the project editor.
- Restart your Acumatica application pool or web server to ensure the new DAC extension loads fully.
2. Duplicate Field Definitions
It’s possible another customization project (or a leftover from a previous test) is defining the same Usr-prefixed fields for APTran. To check:
- Open your customization project in the Customization Project Editor.
- Use the search bar to look up each field name (e.g.,
UsrACAllocModule). - If you find duplicate definitions, remove the conflicting ones and republish.
3. Misconfigured Grid Setup
Double-check that you’ve properly added the fields to the Details tab grid:
- In your customization, navigate to the AP301000 screen’s Details tab.
- Select the grid (bound to
APTran), then go to the Columns section. - Confirm each user field is added, and that the Data Field is set to the correct extension field (e.g.,
APTranExt.usrACAllocModule—note the lowercaseusrin the BQL field name). - Ensure the Visible property is set to
Truefor each field.
4. Database Field Mismatch
Even if the database fields exist, verify their properties match your DAC extension:
- For string fields (
UsrACAllocModule,UsrACAllocBatch,UsrACAllocationID): Confirm the database column isnvarchar(30)(Unicode, length 30). - For the integer field (
UsrACAllocLineNbr): Ensure the database column isint(notsmallintorbigint). - Check that column names in the database exactly match your field names (case shouldn’t matter in SQL Server, but it’s worth confirming).
5. Missing Access Permissions
Your user role might not have rights to view or edit the new fields:
- Go to Security > Access Rights and select your user’s role.
- Find the
APTranDAC (or your custom extension) and ensure the role has Read and Write permissions for each of the 4 user fields.
6. Dig Into Detailed Error Logs
Since you didn’t include the exact error message, the most helpful step is to check Acumatica’s logs:
- Navigate to your Acumatica website’s
App_Data\Logsdirectory. - Look for recent log files (sorted by date) and search for errors related to
APTranor your user fields. The log will usually give a specific reason (e.g., "Field not found", "Type mismatch") that points directly to the issue.
Quick Test to Isolate the Problem
To rule out issues with specific fields, add a simple test user field to your APTranExt DAC:
#region UsrTestField [PXDBString(10)] [PXUIField(DisplayName = "Test Field")] public virtual string UsrTestField { get; set; } public abstract class usrTestField : PX.Data.BQL.BqlString.Field<usrTestField> { } #endregion
Add this field to the grid and republish. If it works, the issue is likely with one of your original 4 fields (e.g., a database mismatch or conflict). If it fails too, the problem is broader (cache, permissions, or project configuration).
内容的提问来源于stack exchange,提问作者pmfith

