ARInvoice.CustomerLocationID - acumatica

The ARInvoice DAC has a field CustomerLocationID. The SQL table ARInvoice does not have a field CustomerLocationID. I have created a SQL View to create a custom DAC from and I need to set the CustomerLocationID from an invoice, in the SQL View, equal to a value to return the correct results. What SQL table holds the field ARInvoice.CustomerLocationID?

ARInvoice herits from ARRegister Class which contains CustomerLocationID field.
Because ARInvoice uses this field it is declared as new abstract in it's class definition:

Using Views is against Acumatica Standard. It is recommended that you create a DAC that is a PXProjection.
Here is an asiablog post about them.
You can find the LocationID in BAccount.
Select the BAccount where the BAccountID is equal to the CustomerID of the Invoice. The field is DefLocationID.
Use the BAccountR DAC to prevent caching issues.

Related

Why does my BQL to select from the database return the current screen's '<NEW>' record?

I have BLC code in the Sales Order screen (SO301000) that uses the RowSelected event to determine whether a CustomerOrderNbr exists for another customer, and to do this, I'm using the following BQL to obtain previously saved records:
//Retrieving the order related to the customer order number
SOOrder soorder2 = PXSelect<SOOrder,
Where<SOOrder.customerOrderNbr, Equal<Required<SOOrder.customerOrderNbr>>,
And<SOOrder.customerID, Equal<Required<SOOrder.customerID>>,
And<Where<SOOrder.orderType, Equal<Constants.qt>,
Or<SOOrder.orderType, Equal<Constants.fi>,
Or<SOOrder.orderType, Equal<Constants.fo>,
Or<SOOrder.orderType, Equal<Constants.fr>>>>>>>>>.Select(Base, soorder.CustomerOrderNbr, soorder.CustomerID);
We never noticed this problem until 2019 R2 - where this BQL select is now bringing back the records currently on the screen, with " <NEW>" as the OrderNbr. I don't want this - I want what's saved in the database.
How can I stop this BQL from returning unsaved current screen records?
You could filter them out using tstamp field:
Where<SOOrder.tstamp, IsNotNull>
Records will have a null tstamp value until they are persisted in database.

What is the difference, PXSelector vs PXDBScalar

I'm trying to figure out when to use PXDBScalar. Do you guys know the difference between PXSelector and PXDBScalar and when to use which one?
In short PXDBScalar is normally used for unbound DAC fields (not stored in the table). For example if you wanted to have a Vendor name handy within a DAC fetch you could configure a DAC field with the vendor name without having to actually store it in the table. Also this works well with GI's.
PXSelector is an attribute for a DAC field that will allow the GUI to perform a look up of 'possible values' as related to the field.
The below explanations are from help.acumatica.com.
PXDBScalar:
Defines the SQL sub request that will be used to retrieve the value for the DAC field.
You should place the attribute on the field that is not bound to any particular database column.
The attribute will translate the provided BQL Search command into the SQL sub request and insert it into the select statement that retrieves data records of this DAC. In the BQL command, you can reference any bound field of any DAC.
Note that you should also annotate the field with an attribute that indicates an unbound field of a particular data type. Otherwise, the field may be displayed incorrectly in the user interface.
You should not use fields marked with the PXDBScalar attribute in BQL parameters (Current, Optional, and Required).
PXSelector:
Configures the lookup control for a DAC field that references a data record from a particular table by holding its key field.

Inventory attribute values DAC

What table(s)/DAC(s) are used to hold the attribute values on the Stock Items screen/Attributes tab? I need to access them in a GI and I can't figure out how.
The Attributes are stored in CSAnswers. The refNoteID in CSAnswers maps to the NoteID in InventoryItem. Each attribute is listed by the AttributeID, so to join specific attribute(s) you'll need to specify the AttributeID also.

Can PXFormula aggregate non-bound fields

I have a header and detail user field of type decimal. Both are not bound to the Db. The value of detail user field is set during RowSelected event. My goal is to accumulate the user field values in the details cache, and assign the value to the header field. Both user fields are defined in cache extensions.
I see PXFormula defines RowSelecting event handler to calculate values for unbound DAC fields. So I define the PXParent & the PXFormula in the child DAC. T200 recommends to add the PXParent in the first FK field. But I defined a cache extension, so a different user field is used.
Unfortunately the header field still displays zero, even though detail field has values. Is this not possible when using non-bound user fields?
Chris, PXFormula (same applies to PXUnboundFormula) has never supported aggregates for unbound header fields. You can still use PXFormula to handle changes the user makes in UI, but this will still require use of a RowSelecting handler from your side to calculate aggregated unbound header fields when record is retrieved from DB.

How to reference new field if it is DAC Extension

I have a couple of new fields in Sales Order (Screen ID - SM204505). I have added these fields from customization project > Data Access. Once published this customization project all the new fields are created in SOOrder table.
Now I want to reference these new fields in my Customization Project in Visual Studio to fill some other values (i.e. add some more business logic).
For example, there is a custom field called UsrReasonCode added to SOOrder table. And then I want to write some business logic to get this value from SOOrder and fill into some other table (i.e. Document Line item > ReasonCode)
It is working if I create Table Extension but I am not sure how to reference if I add it through DAC Extension. Please suggest.
You can reference extension fields by using extension object
like that:
DocExt ext=PXCache<Doc>.GetExtension<DocExt>(doc);
This will get extension object DocExt related to the original Doc object. So you can reference extension fields like ext.UsrField.
To read more about that you can download T300 training from acumatica university

Resources