Skip to main content
Solved

How to fetch values from one dac to another screen?


Forum|alt.badge.img+3

Hello all,

I have a custom field, similar to stock item description in the stock items screen and I am looking to fetch the value from the custom field to my PO screen under the details tab. I have a new field added under the details tab & now want to display in this. How can I do that?

Thanks in advance.

Best answer by Nilkanth Dipak

Hi @Harshita ,

You are adding code to the DAC extension, this is not right. You can add custom fields to the DAC extension and not write an logic.

this code you need to add to the the graph. i.e. public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>

You need to extend POOrderEntry graph and add logic to transfer fields values from one screen to another.

 public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
    {
        protected void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (POLine)e.Row;
            if (row == null) return;

            // Fetch the custom field value from the InventoryItem
            InventoryItem inventoryItem = PXSelect<InventoryItem,
                Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
                .Select(Base, row.InventoryID);

            InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();

            if (inventoryItemExt != null)
            {
                POLineExt rowExt = PXCache<POLine>.GetExtension<POLineExt>(row);
                rowExt.UsrCustomField = inventoryItemExt.UsrCustomField;
            }
        }
    }

 

View original
Did this topic help you find an answer to your question?

11 replies

Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi @Harshita ,

You can use following code snippet to achieve the same.
 

 protected void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (POLine)e.Row;
            if (row == null) return;

            // Fetch the custom field value from the InventoryItem
            InventoryItem inventoryItem = PXSelect<InventoryItem,
                Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
                .Select(Base, row.InventoryID);

            InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();

            if (inventoryItemExt != null)
            {
                POLineExt rowExt = PXCache<POLine>.GetExtension<POLineExt>(row);
                rowExt.UsrCustomField = inventoryItemExt.UsrCustomField;
            }
        }

Hope, it helps!
FYI: This code works only when you updating the Inventory ID field from POLine.

 


Forum|alt.badge.img+3
  • Author
  • Captain II
  • 317 replies
  • July 19, 2024
Dipak Nilkanth wrote:

Hi @Harshita ,

You can use following code snippet to achieve the same.
 

 protected void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (POLine)e.Row;
            if (row == null) return;

            // Fetch the custom field value from the InventoryItem
            InventoryItem inventoryItem = PXSelect<InventoryItem,
                Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
                .Select(Base, row.InventoryID);

            InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();

            if (inventoryItemExt != null)
            {
                POLineExt rowExt = PXCache<POLine>.GetExtension<POLineExt>(row);
                rowExt.UsrCustomField = inventoryItemExt.UsrCustomField;
            }
        }

Hope, it helps!
FYI: This code works only when you updating the Inventory ID field from POLine.

 

Hello @Dipak Nilkanth , thank you for your prompt response. It is throwing the below error:

 


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi @Harshita ,

You are adding code to the DAC extension, this is not right. You can add custom fields to the DAC extension and not write an logic.

this code you need to add to the the graph. i.e. public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>

You need to extend POOrderEntry graph and add logic to transfer fields values from one screen to another.

 public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
    {
        protected void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (POLine)e.Row;
            if (row == null) return;

            // Fetch the custom field value from the InventoryItem
            InventoryItem inventoryItem = PXSelect<InventoryItem,
                Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
                .Select(Base, row.InventoryID);

            InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();

            if (inventoryItemExt != null)
            {
                POLineExt rowExt = PXCache<POLine>.GetExtension<POLineExt>(row);
                rowExt.UsrCustomField = inventoryItemExt.UsrCustomField;
            }
        }
    }

 


Forum|alt.badge.img+3
  • Author
  • Captain II
  • 317 replies
  • July 19, 2024
Dipak Nilkanth wrote:

Hi @Harshita ,

You are adding code to the DAC extension, this is not right. You can add custom fields to the DAC extension and not write an logic.

this code you need to add to the the graph. i.e. public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>

You need to extend POOrderEntry graph and add logic to transfer fields values from one screen to another.

 public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
    {
        protected void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            var row = (POLine)e.Row;
            if (row == null) return;

            // Fetch the custom field value from the InventoryItem
            InventoryItem inventoryItem = PXSelect<InventoryItem,
                Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
                .Select(Base, row.InventoryID);

            InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();

            if (inventoryItemExt != null)
            {
                POLineExt rowExt = PXCache<POLine>.GetExtension<POLineExt>(row);
                rowExt.UsrCustomField = inventoryItemExt.UsrCustomField;
            }
        }
    }

 

Hey @Dipak Nilkanth , 
can you let me know what is the base graph that I shall select?


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi @Harshita ,

POOrderEntry graph, you need to extend.


Forum|alt.badge.img+3
  • Author
  • Captain II
  • 317 replies
  • July 19, 2024
Dipak Nilkanth wrote:

Hi @Harshita ,

POOrderEntry graph, you need to extend.

 


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi @Harshita ,

Have you added custom field in the Inventory item DAC which you needed to pass to the POLine?

 


Forum|alt.badge.img+3
  • Author
  • Captain II
  • 317 replies
  • July 19, 2024
Dipak Nilkanth wrote:

Hi @Harshita ,

Have you added custom field in the Inventory item DAC which you needed to pass to the POLine?

 

Yes, it is in other pkg


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Then, you need to give reference of that package to include the InteventoryItemExt DAC. i.e. using AnotherPackageNamespaceName.


Forum|alt.badge.img+3
  • Author
  • Captain II
  • 317 replies
  • July 19, 2024
Dipak Nilkanth wrote:

Then, you need to give reference of that package to include the InteventoryItemExt DAC. i.e. using AnotherPackageNamespaceName.

What if I add it under same pkg with your above code?


Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

It will helpful to you, if you add custom field of InventoryItem DAC to the same package, So you do not need to give another package reference.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings