如何为客户/供应商ID查找添加CSAnswer属性选择列?已试StackOverflow方案无效
Hey there! Let's work through getting those CSAnswer attributes added to your Customer ID and Vendor ID lookups—since the inventory lookup guide didn't quite work here, we'll tailor the process specifically for customer and vendor screens.
First, make sure the attribute you want to add is actually linked to the Customer and Vendor entities. Head to the Attributes (CS.20.00.00) screen, find your attribute, and confirm its Entity Type is set to both Customer (AR.30.30.00) and Vendor (AP.30.30.00). This ensures the attribute values are tied to the right records.
Next, we need to add custom fields to the lookup data access classes (DACs) for customers and vendors.
For the Customer Lookup, create this DAC extension:
public class CustomerLookupExtension : PXCacheExtension<PX.Objects.AR.CustomerLookup> { #region UsrCustomerAttrValue [PXString] [PXUIField(DisplayName = "Your Attribute Name")] // Replace with your attribute's display name public virtual string UsrCustomerAttrValue { get; set; } public abstract class usrCustomerAttrValue : PX.Data.BQL.BqlString.Field<usrCustomerAttrValue> { } #endregion }
For the Vendor Lookup, use this similar extension:
public class VendorLookupExtension : PXCacheExtension<PX.Objects.AP.VendorLookup> { #region UsrVendorAttrValue [PXString] [PXUIField(DisplayName = "Your Attribute Name")] // Replace with your attribute's display name public virtual string UsrVendorAttrValue { get; set; } public abstract class usrVendorAttrValue : PX.Data.BQL.BqlString.Field<usrVendorAttrValue> { } #endregion }
Note: Replace UsrCustomerAttrValue/UsrVendorAttrValue with a meaningful field name, and update the DisplayName to match your attribute.
Now we need to pull the actual CSAnswer values into the lookup views by modifying the customer and vendor maintenance graphs.
For Customer Maintenance:
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint> { public override void Initialize() { base.Initialize(); // Define your attribute ID as a constant (replace "YOUR_CUSTOMER_ATTR_ID" with your actual ID) const string CustomerAttrID = "YOUR_CUSTOMER_ATTR_ID"; // Add CSAnswer value to the customer lookup view Base.CustomerLookupView.View.Select.Add( typeof(CSAnswer.value).Column .Where( CSAnswer.refNoteID.IsEqual<Customer.noteID>() .And(CSAnswer.attributeID.IsEqual(CustomerAttrID)) ) ); } }
For Vendor Maintenance:
public class VendorMaint_Extension : PXGraphExtension<VendorMaint> { public override void Initialize() { base.Initialize(); // Replace "YOUR_VENDOR_ATTR_ID" with your actual attribute ID const string VendorAttrID = "YOUR_VENDOR_ATTR_ID"; // Add CSAnswer value to the vendor lookup view Base.VendorLookupView.View.Select.Add( typeof(CSAnswer.value).Column .Where( CSAnswer.refNoteID.IsEqual<Vendor.noteID>() .And(CSAnswer.attributeID.IsEqual(VendorAttrID)) ) ); } }
Now let's add the new fields to the lookup screens:
- Open your customization project, navigate to the Customer Lookup (AR.30.30.00) screen
- Open the Layout Editor, find the section where you want to add the attribute column
- Drag your custom
UsrCustomerAttrValuefield from the "Available Fields" panel into the layout - Repeat the same process for the Vendor Lookup (AP.30.30.00) screen, adding the
UsrVendorAttrValuefield
Save and publish your customization project, then:
- Open the Customers (AR.30.30.00) screen, click the magnifying glass next to Customer ID—you should see your new attribute column
- Do the same for the Vendors (AP.30.30.00) screen
If the field doesn't show up, check these common issues:
- Did you set the correct Entity Type for your CSAnswer attribute?
- Is the attribute ID in your graph extension an exact match to the attribute's ID in the CS.20.00.00 screen?
- Are there any errors in the System Monitor (SM.20.50.50) that might point to a query or DAC issue?
内容的提问来源于stack exchange,提问作者RuslanDev

