Solved

linking data fields on different pages

  • 28 November 2023
  • 15 replies
  • 117 views

so, basically I have 2 different pages, both with a (vip checkbox) data field. one page is a customerClass and the second page is a customer page. the customer page is kind of an instance of the customerclass so when a record for customer is created, certain fields are already populated with information from the customer class. the vip checkbox is a custom field that i created and i want to know how i can link them so when the checkbox on customerclass is ticked, the customer records created take that value and tick its own vip checkbox. im new to acumatica so please explain in detail if you can

this is customer class,see the vip box on the right? if i tick that, when i generate a customer record, its vip box should already be ticked

this is the customer page. when i create a new record, the vip box should already be ticked if the customerclass vip box is ticked

icon

Best answer by darylbowman 4 December 2023, 14:07

View original

15 replies

Badge +11

What you want is to default the value of your custom field on Customers to the value of your custom field on CustomerClass. You could use a FieldDefaulting event to achieve this, but the easier option is to define a default value on the DAC field. This is similar to how your custom field definition should look on your DAC extension for Customer:

#region UsrCustomField2
[PXDBBool]
[PXDefault(typeof(SearchFor<CustomerClassExt.usrCustomField2>.
In<SelectFrom<CustomerClass>. Where<CustomerClass.customerClassID.IsEqual<Customer.customerClassID.FromCurrent>>>))]
[PXFormula(typeof(Default<Customer.customerClassID>))]
[PXUIField(DisplayName="Custom Field 2")]
public virtual bool? UsrCustomField2 { get; set; }
public abstract class usrCustomField2 : PX.Data.BQL.BqlBool.Field<usrCustomField2> { }
#endregion

The [PXDefault] attribute will search the customer class value that matches the current record’s customer class.

The [PXFormula] will cause the default value to be recalculated when the CustomerClassID of the Customer is changed.

Badge +11

I posted a reply, but it got stuck in moderation. It may be a bit until it shows up.

thanks for responding. how would i go about doing it with an event handler? would i just paste that code into the customer dac? and replace the field name (usrcustomfield2 with Usrvip)

Badge +11

Is there a particular reason you want to use a graph event handler?

getting errors trying to put it in the dac. I have “customer” that has the region/field defenitions and then the Customermaint which would be the graph. how do i get to customer’s extension? I was trying some other things and i referred to customer as the dac extension but apperently thats the actual dac according to chatgpt..the code you provided im supposed to implement in ‘customer’ and im supposed to substitute Usrcustomfield with my custom field Usrvip right?

i generated another customer dac extension and it already had a usrcustomfield definition. is that where im supposed to implement the code? is it supposed to be Usrcustomfield2 or am i supposed to change it to vip?

 

Badge +11

You need to replace my code field name with your VIP field and the field name on CustomerClass.

You should already have a DAC extension where your custom field is defined, UNLESS you used the DAC field generator thingy. In that case, you'd have to define one like you did. It includes a sample field 'UsrCustomField' which you can remove and replace with your specs.

published successfully, tried opening the page and this pops up, i cannot edit the page(layout,add controls e.t.c)in the project customizer

Badge +11

So you had used the DAC field generator thingy. You need to go delete that first because now the field is being defined in two places.

and the where do i put the code? because prior to me generating those dacs, there was nothing under code.

i’ve created new dacs that generate the fields from the database. my customers dac doesnt have a vip field even tho i have it on the page, i implemented the code on customers and it went through, tested it and it isnt working. how can i get the dac extensions? the one that already exists and where the fields im trying to reference are?

Badge +11

Could you share your package?

here

Userlevel 7
Badge

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

yes 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