Skip to main content
Solved

Unable to create custom lookup field to business account


I’m new to development and customization with Acumatica.  I’m attempting to add a new field to Business Account.  It’s going to be a lookup to the Employee records.I discovered that employee records are stored in the Business Account table.  So it’s a lookup back to BAccount for the employee record. 
Requirements are to setup a secondary owner for Business Accounts. 
 

This is the only information I’ve added to the attribute field: 
[PXDBInt]
[PXSelector(
    typeof(Search<BAccount.BAccountID,
        Where<BAccount.Type,Equal<EP>>>),
    typeof(BAccount.AcctCD),
    typeof(BAccount.LegalName),
    SubstituteKey = typeof(BAccount.AcctCD),
    DescriptionField = typeof(BAccount.LegalName)]
[PXUIField(DisplayName="SecondaryOwner2")]
Everytime I go to publish the information I get an error.  

\App_RuntimeCode\PX_Objects_CR_BAccount_extensions.cs(29): error CS0426: The type name 'AcctCD' does not exist in the type 'BAccount'Any assistance would be greatly appreciated. 

Best answer by aaghaei

@prachayang

Assuming the field you have is an INT field, use the below properties instead of ALL of the existing ones. It has both Field Type and selector inside and filters on all Active Employees.

[PX.Objects.AP.VendorActive(typeof(Search<PX.Objects.AP.Vendor.bAccountID, Where<PX.Objects.AP.Vendor.type, Equal<PX.Objects.CR.BAccountType.employeeType>>>),
    DescriptionField = typeof(PX.Objects.AP.Vendor.acctName),
    DisplayName = "Employee",
    Visibility = PXUIVisibility.SelectorVisible, Visible = true,
    Required = false, Enabled = true, CacheGlobal = true, Filterable = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]

 

View original
Did this topic help you find an answer to your question?

9 replies

Laura02
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3132 replies
  • March 20, 2023

Have you considered handling the above new field with Attributes? Selector Attributes provide ability to look up into the Employees list with no code.


  • Author
  • Freshman I
  • 2 replies
  • March 20, 2023

I have, but for a better user experience, they’re asking for the field to be on the same screen.  Unless there’s a way to move attributes to the Summary section of the screen.  


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1201 replies
  • March 20, 2023

if you want only employee list there is a built-in selector that can be called as [Employee]


iqraharrison
Captain II
Forum|alt.badge.img+8
  • Captain II
  • 555 replies
  • March 20, 2023

@prachayang you may be able to create a “user defined field” as an alternative.  this would be similar to an attribute though 


  • Author
  • Freshman I
  • 2 replies
  • March 20, 2023

@aaghaei do you have an idea of how I might add that.  I did a bit a research and it seems the Employee selector is called EPEmployee.  
I replaced the selector code with this: 
[PXSelector(
    typeof(Search<EPEmployee.BAccountID>),
    typeof(EPEmployee.acctCD),
    typeof(EPEmployee.acctName),
    SubstituteKey = typeof(EPEmployee.acctCD),
    DescriptionField = typeof(EPEmployee.acctName)]

but i’m getting a different kind of error

\App_RuntimeCode\PX_Objects_CR_BAccount_extensions.cs(37): error CS0426: The type name 'BAccountID' does not exist in the type 'EPEmployee'

aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1201 replies
  • Answer
  • March 21, 2023

@prachayang

Assuming the field you have is an INT field, use the below properties instead of ALL of the existing ones. It has both Field Type and selector inside and filters on all Active Employees.

[PX.Objects.AP.VendorActive(typeof(Search<PX.Objects.AP.Vendor.bAccountID, Where<PX.Objects.AP.Vendor.type, Equal<PX.Objects.CR.BAccountType.employeeType>>>),
    DescriptionField = typeof(PX.Objects.AP.Vendor.acctName),
    DisplayName = "Employee",
    Visibility = PXUIVisibility.SelectorVisible, Visible = true,
    Required = false, Enabled = true, CacheGlobal = true, Filterable = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1201 replies
  • March 21, 2023

Oh, also I fully qualified the objects “PX.Obj...” because I was unsure where you will be putting these definitions and how you are going to declare the directives.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • March 21, 2023

@prachayang  Please share your customization package, so that we can review that error while publishing and help you to resolve it.


Forum|alt.badge.img
  • Semi-Pro II
  • 122 replies
  • March 6, 2025

 

HI ​@aaghaei Thank you for the code, I was able to create a custom field selecting from the employee list on business account screen. I was wondering if you could help me understand why five different fields are created? 

 

 

I tried publishing just the first one with SegmentMast Control, while I was able to get it on the business account screen and select an employee and save the document. But I was also receiving the below error:

 

 

Am I doing something wrong here? Do I need to have the AP Vendor part in the code for this to work?

If you could point in the right direction that would be great! Thank you!!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings