Skip to main content
Question

Trying to create a custom Field that defaults from another custom field


Forum|alt.badge.img

I am working in the Customization Project Editor.  I went in and added on the Customer Screen a new custom field usrDate_Of_Loss.  I think its BAccountExt.usr_Date_Of_Loss.  I added it to the customer. 

I also added a usrDateOfLoss to the invoice 

ARRegisterExt.usrDateOfLoss I believe is what it is called. 

I also added the Default code and the Formula attributes where the custom field is declared in the Customization Project Editor.  I am  adding it to the Attributes section,  I put in bold below: 

 

[PXDBDate]
[PXUIField(DisplayName="Date Of Loss")]

[PXDefault(typeof(Search<BAccountExt.usrDate_Of_Loss , 
            Where<Customer.CustomerID, Equal<Current<ARInvoice.CustomerID>>>>), 
            PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(Default<ARInvoice.CustomerID>))]

 

It is looking up I hope that custom field from Customer to put in the Invoice DateofLoss Field. 

The error on validation is: 

\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(36): error CS0426: The type name 'CustomerID' does not exist in the type 'Customer'
\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(36): error CS0426: The type name 'CustomerID' does not exist in the type 'ARInvoice'
\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(38): error CS0426: The type name 'CustomerID' does not exist in the type 'ARInvoice'
\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(36): error CS0426: The type name 'CustomerID' does not exist in the type 'Customer'

 

Do I need to add declarations to the Attributes section in Customization Project Editor, that doesn’t seem to make sense. Any help would be appreciated.

Image below

 

20 replies

Shawn Burt
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • 109 replies
  • August 30, 2022

your issue is Casing. Types in this area are camel case with the first letter being lower case.

So it should be ARInvoice.customerID

The field names after the dot should be lowercase.this would be everywhere in those attributes. Your custom field is good but the rest need adjusted.


Forum|alt.badge.img

Thats fantastically simple to fix. Thank you!


Forum|alt.badge.img

And to close the loop, Customer.CustomerID had to be Customer.acctCD.  So changing case and the wrong field made it work.  Thanks


Forum|alt.badge.img

But the default is not working of course...


Forum|alt.badge.img+6
  • Captain II
  • 564 replies
  • August 30, 2022

Something else to watch for is that you should avoid using the underscore character in your DAC field names.


Shawn Burt
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • 109 replies
  • August 30, 2022

@ddunn thanks for pointing that out. I had meant to mention it. In Acumatica Business Logic the underscores drive some of the functionality and if you have underscores in your field names it can make other customization harder. I won’t necessarily break anything but will make it harder to customize business logic related to those fields later.


darylbowman
Captain II
Forum|alt.badge.img+13

@edwardmcgovern97  Try this Default Attribute: 

[PXDefault(typeof(SearchFor<BAccountExt.usrDate_Of_Loss>.
            In<SelectFrom<BAccount>.
                    Where<BAccount.bAccountID.IsEqual<ARInvoice.customerID>>>))]

You’ll need to have the using:

using PX.Data.BQL.Fluent;

 


Forum|alt.badge.img

Are we saying that the default is not happening because of the underscores? 

 


darylbowman
Captain II
Forum|alt.badge.img+13

@edwardmcgovern97 - No, it’s just not a best practice.


darylbowman
Captain II
Forum|alt.badge.img+13

If I’m right, the default is not happening because you’re searching for the value of a DAC extension of BAccount, but your Where is pulling from Customer (a completely different table). You could also change your statement to:

[PXDefault(typeof(Search<BAccountExt.usrDate_Of_Loss, 
            Where<BAccount.baccountID, Equal<Current<ARInvoice.customerID>>>>), 
            PersistingCheck = PXPersistingCheck.Nothing)]

I don’t like the old BQL so I used F-BQL


Forum|alt.badge.img

Ok I am trying the code you suggested and it does not seem to fire. I get no default

 


darylbowman
Captain II
Forum|alt.badge.img+13

Apologies, I didn’t see you were using the visual editor. I don’t believe you can use ‘using’ there. F-BQL may work there without that, or if not, use my BQL version.


Forum|alt.badge.img

I get no prompt for anything missing when I compile without the using and deploy and still get no default using yours or my code


darylbowman
Captain II
Forum|alt.badge.img+13

I may have been wrong about the tables. I actually think that since they restructured the BAccount and Customer relation, you may have been right. However, in your original attribute, you used Customer.customerID, which is not a valid field, as you saw, but Customer.acctCD is also not going to match.

Try this: 

[PXDefault(typeof(Search<BAccountExt.usrDate_Of_Loss , 
            Where<Customer.baccountID, Equal<Current<ARInvoice.customerID>>>>), 
            PersistingCheck = PXPersistingCheck.Nothing)]

 

I’m not sure if you need the Current<> or not. I’d try it both ways.

Don’t think I can help you more than that.


Forum|alt.badge.img

Got it.  Customerid is an integer.  Acctcd is the string holding the account 

But I tried yours and 

\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(36): error CS0426: The type name 'baccountID' does not exist in the type 'Customer'
\App_RuntimeCode\PX_Objects_AR_ARRegister_extensions.cs(36): error CS0426: The type name 'baccountID' does not exist in the type 'Customer'

darylbowman
Captain II
Forum|alt.badge.img+13

Sorry, case again.

 

[PXDefault(typeof(Search<BAccountExt.usrDate_Of_Loss , 
            Where<Customer.bAccountID, Equal<Current<ARInvoice.customerID>>>>), 
            PersistingCheck = PXPersistingCheck.Nothing)]

 


Forum|alt.badge.img

Its not defaulting.  I’m wondering if the problem is the 

[PXFormula(typeof(Default<ARInvoice.CustomerID>))]

which I thought was trying to trigger the default after customerID has changed


Forum|alt.badge.img

I tried to set it to a different field

[PXFormula(typeof(Default<ARInvoice.dueDate>))]

and it still doesn’t work. When I change DueDate the field doesn’t default

 

What I am trying to do is change the value of the user_Date_Of_Loss to the usrDateOfLoss from the Customer screen when the customer is selected.   Should I put this on the change event of the customer or somewhere else????


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2759 replies
  • November 1, 2022

Hi @edwardmcgovern97 - were you able to find a solution? Thank you!


kdavis45
Semi-Pro I
Forum|alt.badge.img+1
  • Semi-Pro I
  • 41 replies
  • August 30, 2023

@darylbowman Thank you for the (patient) explanation about case sensitivity - it helped me finish up a customization today!


Reply


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