Skip to main content

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]
     rCustomerActive(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

 

Hi,

try to use simple approach for search:

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


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 


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.


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


Hi @ddunn ,

Yes i did it


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.


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