Solved

How to pick currency code when select the customer in my customized screen

  • 24 January 2023
  • 7 replies
  • 65 views

Userlevel 3
Badge

Hi,

I’m new to the acumatica development and I had to create a new screen, In the screen I need to get customer currency code after the customer is selected.

This is my DAC code for customer

     #region CustomerID
     [PXDefault]
     [CustomerActive(DisplayName = "Customer",DescriptionField = typeof(Customer.acctName))]
     public virtual int? CustomerID { get; set; }
     public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }
      #endregion

This is my Field Update event is Graph.cs file

      protected void _(Events.FieldUpdated<APProforma,
            APProforma.customerID> e)
        {
            APProforma row = e.Row;
            if (row.CustomerID != null)
            {
               
                Customer cust = PXSelectorAttribute.Select<
                    APProforma.customerID>(e.Cache, row) as Customer;
                
               
                row.currency = cust.CuryID;
                
            }
           
        }

After I adding the above code into my graph in the screen customer name is not set with customer field.

Anyone can help for this.

Below i have add both DAC and graph file for your reference.

Thanks You

 

icon

Best answer by andriikravetskyi35 24 January 2023, 14:27

View original

7 replies

Userlevel 5
Badge +1

Hi,

try to use simple approach for search:

 var customer = Customer.PK.Find(this, row.CustomerID)?.TopFirst;

Userlevel 3
Badge

Hi @andriikravetskyi35 ,

Do you mean replace the above code suggested for the Customer cust = PXSelectorAttribute.Select<
                    APProforma.customerID>(e.Cache, row) as Customer;

field

Thank you for your rly and waiting for your response 

Userlevel 5
Badge +1

yes, remove your PXSelectoAttribute, and paste Customer.PK.Find() method. 

In 21 and 22 versions of Acumatica, search method PK.Find() implemented for the most of tables and you can use it.

Userlevel 7
Badge +5

Did you set CommitChanges to True for your Customer field in the screen editor/aspx?

Userlevel 3
Badge

Hi @ddunn ,

Yes i did it

Userlevel 7
Badge +5

The code that you included in the zip file doesn’t match the code from your question.  This line:

row.currency = cust.CuryID;

should be:

row.Currency = cust.CuryID;

You’ve also set up your Currency field as a string list but your screen doesn’t appear to be using a drop down control.

Try updating the control on the screen.

The customer field declaration looks correct so I’m not sure why the name isn’t appearing.  However, you might benefit from restarting the application (Apply Updates, Restart Application) just to clear out any cached data.

Userlevel 3
Badge

Hi @ddunn ,

I will try restart my application. But when the issue coming I removed the event field for my graph file then customer name is set correctly. Only when the add event customer name is not set with customer field.

 

Thank you

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved