Solved

Code Question: Get value of field from grid


Hi All,

 

In the code snippet below, how do I access the value for the field TranCost? I can’t get to it using row.tranCost. This is on the screen PO303000.

 

        protected void POLandedCostReceiptLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
        {
            var row = (POLandedCostReceiptLine)e.Row;

        }

 

When I use row.tranCost I get the following error:

 

\App_RuntimeCode\POLandedCostDocEntry.cs(220): error CS1061: 'object' does not contain a definition for 'tranCost' and no accessible extension method 'tranCost' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

 

Maybe I just have the field name wrong. I am trying to get to the Extended Cost amount for the line. I tried inspecting but I am not able to because the grid is not editable so I always only get the details for the whole grid and not the column I click on. I looked at the table in the database and the field is named TranCost.

icon

Best answer by Naveen B 6 July 2021, 20:08

@abbas56  Below is the code to fetch the Extended Cost field value from POLandedCostReceiptLine DAC.

 

LineAmt is the DAC field name, and Ext Cost is the UI name.

 

  public class POLandedCostDocEntryExt : PXGraphExtension<POLandedCostDocEntry>
{
protected void POLandedCostReceiptLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
{
POLandedCostReceiptLine row = (POLandedCostReceiptLine)e.Row;
if (row != null)
{
var ExtendedCost = row.LineAmt;
}

}
}

 

View original

9 replies

Userlevel 1
Badge

I think you’re looking for row.TranCost.  The capitalized property is the field value.

Tried that. Same result.

Userlevel 1
Badge

Can you show us more code?

Userlevel 6
Badge +8

Hi @abbas56  We do not have TranCost field in POLandedCostReceiptLine DAC, hence you are getting that issue.

Can you please let me know from screen (Screenshot), which field you are trying to get the value. 

 

Userlevel 6
Badge +8

@abbas56  Below is the code to fetch the Extended Cost field value from POLandedCostReceiptLine DAC.

 

LineAmt is the DAC field name, and Ext Cost is the UI name.

 

  public class POLandedCostDocEntryExt : PXGraphExtension<POLandedCostDocEntry>
{
protected void POLandedCostReceiptLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
{
POLandedCostReceiptLine row = (POLandedCostReceiptLine)e.Row;
if (row != null)
{
var ExtendedCost = row.LineAmt;
}

}
}

 

Thanks Naveen. I'll try that out and report back. Is there a resource website that lists all the fields available in a DAC?

 

Regards,

Abbas

Userlevel 6
Badge +8

Yes @abbas56 You can see all the DAC field names with the below steps.

  • Inspect the Element on the Grid
  • Click on the Actions and then click on the View Data Class Source.

Please find the screenshot for reference.

 

Thank you Naveen. Your information really helped and resolved my issue.

 

 

Userlevel 6
Badge +8

That is wonderful.. Thanks for sharing an update :)

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 — 2020  Acumatica, Inc. All rights reserved