Skip to main content
Solved

How to Pass Non-Persisting (Unbound) Custom Fields from Stock Items to Sales Orders in Acumatica

  • January 22, 2025
  • 17 replies
  • 320 views

DipakNilkanth
Pro III
Forum|alt.badge.img+13

Hi Community,

I'm trying to transfer three unbound custom fields from the Stock Items screen to the Sales Orders screen. These fields are non-persisting and should only be displayed in the Sales Orders screen without being saved in the database.

What I Have Tried:

  1. PXDBScalar Approach:

    • I used the [PXDBScalar] attribute in the SOLine DAC to fetch values from the InventoryItem table, but the fields return null.

    Example:

     
    [PXDBScalar(typeof(Search<InventoryItemExt.usrTI, Where<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>))] 
    [PXInt]
    [PXUIField(DisplayName = "TI")]
    public virtual int? UsrTI { get; set; }
    public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { }

     

  2. FieldUpdated Event Handler:

    • I created a PXGraph instance within the SOLine_InventoryID_FieldUpdated event to fetch values using PXSelect, but the fields still remain null.

    Example:

    protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) 
    { var row = (SOLine)e.Row;
    if (row == null || row.InventoryID == null) return;
    var inventoryGraph = PXGraph.CreateInstance<PXGraph>();
    InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>> .Select(inventoryGraph, row.InventoryID);
    if (inventoryItem != null)
    {
    InventoryItemExt itemExt = inventoryItem.GetExtension<InventoryItemExt>();
    SOLineExt rowExt = cache.GetExtension<SOLineExt>(row);
    if (itemExt != null && rowExt != null)
    {
    rowExt.UsrTI = itemExt.UsrTI ?? 0;

    cache.SetValueExt<SOLineExt.usrTI>(row, rowExt.UsrTI);
    }
    }
    }

     

Issue:

Despite these approaches, the values are still not populating in the Sales Orders screen. When I select an inventory item, the custom fields remain null.

Question:

How can I properly transfer these non-persisting fields from Stock Items to Sales Orders? Are there any alternative approaches or best practices for handling such cases?

Any insights or suggestions would be greatly appreciated!

Thanks in advance.

Best answer by DipakNilkanth

@Django 

I tried using the FieldSelecting event to retrieve values from custom fields, but I encountered an issue where the values were coming in as `null`.  

 

After discussing with the client, it was confirmed that saving the data directly in the InventoryItem DAC is necessary to ensure the values are available when needed. The client agreed to this approach.  

 

To achieve this, I utilized the PXFormula attribute in DAC level to automatically populate the required fields by comparing the `InventoryID` from the SOLine DAC. With this approach, the correct data entered in the Stock Item screen is now successfully passed for the respective stock item.  

 

This solution has resolved the issue and ensures the expected values are properly carried over.

Thanks for the suggestions.

17 replies

Forum|alt.badge.img
  • Varsity I
  • January 22, 2025

HI ​@Nilkanth Dipak 

Please try this below!

1. Use a Custom Field with [PXFormula] Attribute

The PXFormula attribute is the most straightforward and efficient way to fetch values from related records without persisting the data. It automatically calculates the value based on your defined formula.

Example:

In the SOLine DAC, define your custom field like this:

[PXInt]
[PXUIField(DisplayName = "TI")]
[PXFormula(typeof(Selector<SOLine.inventoryID, InventoryItemExt.usrTI>))]
public virtual int? UsrTI { get; set; }
public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { }
  • Explanation:
    • The PXFormula attribute dynamically populates the value from the InventoryItemExt.usrTI field using the Selector on the SOLine.inventoryID field.
    • Since it’s not persisted, the value is only displayed on the UI but not saved in the database.

2. Ensure the Field Is in the Selector of the Inventory Item

The PXFormula approach relies on the field (usrTI) being included in the Selector for the inventoryID field.

  • Modify the InventoryItem DAC to ensure the usrTI field is part of the selector:
[PXCustomizeSelectorColumns(
typeof(InventoryItem.inventoryCD),
typeof(InventoryItem.descr),
typeof(InventoryItemExt.usrTI))] // Add your custom field here

This ensures the custom field is accessible when the system resolves the selector.

3. Alternative: Use a FieldUpdated Event

If the PXFormula approach does not meet your requirements, you can use a FieldUpdated event to fetch and populate the custom fields dynamically.

Updated Example:

protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (SOLine)e.Row;
if (row == null || row.InventoryID == null) return;

// Fetch the Inventory Item using PXSelectorAttribute
InventoryItem inventoryItem = PXSelectorAttribute.Select<InventoryItem.inventoryID>(cache, row) as InventoryItem;
if (inventoryItem != null)
{
InventoryItemExt itemExt = inventoryItem.GetExtension<InventoryItemExt>();
SOLineExt rowExt = row.GetExtension<SOLineExt>();

if (itemExt != null && rowExt != null)
{
rowExt.UsrTI = itemExt.UsrTI ?? 0;
cache.SetValueExt<SOLineExt.usrTI>(row, rowExt.UsrTI);
}
}
}
  • Key Points:
    • Use PXSelectorAttribute.Select to fetch the InventoryItem instead of creating a new graph instance.
    • This ensures that the selected InventoryItem is already loaded in memory and avoids performance issues.

4. Verify the Extension Structure

Ensure that your DAC extensions are correctly defined for both InventoryItem and SOLine.

For example:

InventoryItem DAC Extension:

public class InventoryItemExt : PXCacheExtension<InventoryItem>
{
[PXInt]
[PXUIField(DisplayName = "TI")]
public virtual int? UsrTI { get; set; }
public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { }
}

SOLine DAC Extension:

public class SOLineExt : PXCacheExtension<SOLine>
{
[PXInt]
[PXUIField(DisplayName = "TI")]
public virtual int? UsrTI { get; set; }
public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { }
}

5. Debug and Validate the Process

  • Ensure the Field Is Loaded Properly: Use the debugger to validate that the InventoryItemExt.usrTI field is populated correctly when an InventoryID is selected.

  • Clear Cache: If changes are not reflecting, clear the Acumatica cache by navigating to System > Clear Cache.

6. Considerations

  • Non-Persisting Fields: Since the fields are non-persisting, they will only be calculated and displayed in the UI and won’t be saved to the database.
  • Performance: The PXFormula approach is recommended for better performance, as it avoids unnecessary graph instances and queries.

By implementing the above steps, the custom fields should dynamically populate on the Sales Orders screen when an inventory item is selected, without requiring persistence in the database.


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

Hi ​@smuddurthi81,

I tried PXFormula but did not work for me. I noticed that on the Stock Items screen, when I refresh the screen, the unbound fields do not retain any data. This makes me unsure whether the values are being copied correctly or not.


Forum|alt.badge.img
  • Varsity I
  • January 22, 2025

Can you please try this!

The behavior you're encountering with unbound fields in Acumatica is expected because unbound fields do not store data in the database—they are meant for calculated or transient values. When the screen is refreshed, unbound fields will lose their values unless explicitly re-populated.

Here’s how you can properly handle unbound fields and ensure the values are displayed correctly on the Sales Orders screen:

  1. Understanding the Issue

    • Unbound Fields: These are not stored in the database. Values are calculated or fetched dynamically and need to be refreshed explicitly.
    • Why PXFormula Might Not Work:
      • PXFormula works for bound fields or for dynamically calculated values tied to data operations. It doesn't retain data for unbound fields after a screen refresh because it lacks persistence.
      • If the field value depends on external logic or conditions (like fetching data from another table), PXFormula alone is insufficient.
  2. Proper Solution for Unbound Fields
    To address the issue, you can use the following approaches:

    Option 1: Use FieldDefaulting Event
    The FieldDefaulting event is triggered whenever a value needs to be calculated for an unbound field.

    Example:
    In the SOLine DAC, add the event handler to fetch the value from the InventoryItem table:

    protected void _(Events.FieldDefaulting<SOLine, SOLineExt.usrTI> e)
    {
    var row = e.Row;
    if (row == null || row.InventoryID == null) return;

    // Fetch the related inventory item
    InventoryItem inventoryItem = PXSelect<InventoryItem,
    Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
    .Select(Base, row.InventoryID);

    if (inventoryItem != null)
    {
    // Get the custom field value from the InventoryItem
    InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();
    e.NewValue = inventoryItemExt?.UsrTI;
    }
    }

    How it works:

    • When the field is accessed (e.g., screen load, grid refresh), this event fetches the value from the InventoryItem table and populates the unbound field.

    Option 2: Use FieldUpdated Event
    If you want the value to update dynamically when the InventoryID changes, use the FieldUpdated event.

    Example:

    protected void _(Events.FieldUpdated<SOLine, SOLine.inventoryID> e)
    {
    var row = e.Row;
    if (row == null || row.InventoryID == null) return;

    // Fetch the inventory item based on InventoryID
    InventoryItem inventoryItem = PXSelect<InventoryItem,
    Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
    .Select(Base, row.InventoryID);

    if (inventoryItem != null)
    {
    // Populate the unbound field
    InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();
    SOLineExt solineExt = PXCache<SOLine>.GetExtension<SOLineExt>(row);

    solineExt.UsrTI = inventoryItemExt?.UsrTI;

    // Update the UI
    e.Cache.SetValueExt<SOLineExt.usrTI>(row, solineExt.UsrTI);
    }
    }

    How it works:

    • When the InventoryID field is updated, the event fetches the value from the InventoryItem table and populates the unbound field.

    Option 3: Populate on RowSelected Event
    If you need to populate the unbound field dynamically whenever the row is selected, use the RowSelected event.

    Example:

    protected void _(Events.RowSelected<SOLine> e)
    {
    var row = e.Row;
    if (row == null || row.InventoryID == null) return;

    // Fetch the inventory item based on InventoryID
    InventoryItem inventoryItem = PXSelect<InventoryItem,
    Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>
    .Select(Base, row.InventoryID);

    if (inventoryItem != null)
    {
    // Populate the unbound field
    InventoryItemExt inventoryItemExt = inventoryItem.GetExtension<InventoryItemExt>();
    SOLineExt solineExt = PXCache<SOLine>.GetExtension<SOLineExt>(row);

    solineExt.UsrTI = inventoryItemExt?.UsrTI;

    // Update the UI
    e.Cache.SetValueExt<SOLineExt.usrTI>(row, solineExt.UsrTI);
    }
    }
  3. Key Considerations

    • Caching: Use the PXSelect statements cautiously to avoid performance issues when working with large data sets.
    • Ensure the Field is Displayed Properly:
      • Add [PXUIField(DisplayName = "TI")] to ensure the field appears correctly in the UI.
      • Mark the field with [PXInt] or [PXString] based on its data type.
  4. Troubleshooting Tips

    • Screen Refresh Issue: If the field is not displaying values after a refresh:
      • Ensure the FieldDefaulting or RowSelected logic is working as expected.
      • Use debugging tools to confirm the values are fetched and assigned correctly.
    • Null Values: If the fields return null, double-check:
      • The InventoryID is populated.
      • The InventoryItem table contains the expected data.

 


Forum|alt.badge.img+8
  • Captain II
  • January 22, 2025

HI ​@Nilkanth Dipak 

 

I did something similar with a RowSelected Event for the ARSalesPriceMaint, might be worth a try.

#region Event Handlers
protected virtual void _(Events.RowSelected<ARSalesPrice> e, PXRowSelected b)
{
b?.Invoke(e.Cache, e.Args);
ARSalesPrice row = e.Row;
if(row == null) return;

ARSalesPriceExt rowExt = PXCache<ARSalesPrice>.GetExtension<ARSalesPriceExt>(row);
if(rowExt == null) return;

InventoryItemCurySettings costs = SelectFrom<InventoryItemCurySettings>.
Where<InventoryItemCurySettings.inventoryID.IsEqual<P.AsInt>>.View.Select(Base, row.InventoryID);
if(costs == null) return;

rowExt.UsrUnitCost = costs.StdCost;


}
#endregion

Hope this helps,

Aleks


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

Hi ​@aiwan,

Thanks for your response.

My issue is that both screens contain unbound custom fields, and whenever I try to retrieve the values of these fields, they always return null.

I need your suggestions on whether it is possible to retrieve the values of unbound custom fields from Stock Items screen to Sales Orders screen.

Currently, when I try to save these custom field values, they appear to stay temporarily, but after refreshing the screen, they go blank.


Hope, it clarifies the situation.

 


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

HI ​@Nilkanth Dipak 

 

I did something similar with a RowSelected Event for the ARSalesPriceMaint, might be worth a try.

#region Event Handlers
protected virtual void _(Events.RowSelected<ARSalesPrice> e, PXRowSelected b)
{
b?.Invoke(e.Cache, e.Args);
ARSalesPrice row = e.Row;
if(row == null) return;

ARSalesPriceExt rowExt = PXCache<ARSalesPrice>.GetExtension<ARSalesPriceExt>(row);
if(rowExt == null) return;

InventoryItemCurySettings costs = SelectFrom<InventoryItemCurySettings>.
Where<InventoryItemCurySettings.inventoryID.IsEqual<P.AsInt>>.View.Select(Base, row.InventoryID);
if(costs == null) return;

rowExt.UsrUnitCost = costs.StdCost;


}
#endregion

Hope this helps,

Aleks

In your case, StdCost is saving to DB So we can able to fetch it in our custom field, In my case both screens have Unbound custom fields.


Forum|alt.badge.img+7
  • Captain II
  • January 22, 2025

Going back to your original question - something I don’t see that you’ve been asked is how are you calculating the non-persisted field in the InventoryItem DAC? All of the code above is correct for updating SOLine but if you’re InventoryItem field is returning null then we’re looking in the wrong place.


Forum|alt.badge.img
  • Varsity I
  • January 22, 2025

@Django please check my second reply hope it's helpful 


Forum|alt.badge.img+7
  • Captain II
  • January 22, 2025

What is the DAC declaration for the InventoryItem field?


Forum|alt.badge.img
  • Varsity I
  • January 22, 2025

@Django The DAC (Data Access Class) declaration for the `InventoryID` field in Acumatica, as found in the `InventoryItem` DAC, is typically defined as follows:

 

```csharp

#region InventoryID

[PXDBIdentity]

[PXSelector(

    typeof(Search<InventoryItem.inventoryID>),

    typeof(InventoryItem.inventoryCD),

    typeof(InventoryItem.descr),

    SubstituteKey = typeof(InventoryItem.inventoryCD),

    DescriptionField = typeof(InventoryItem.descr)

)]

[PXUIField(DisplayName = "Inventory ID")]

public virtual int? InventoryID { get; set; }

public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }

#endregion

```

 

Key Attributes Explanation:

 

1. PXDBIdentity:  

   Indicates that the field is an auto-incrementing identity column in the database.

 

2. PXSelector:  

   Configures a lookup control for the field. It specifies the fields to display in the selector (such as `InventoryCD` and `Descr`) and the substitute key (`InventoryItem.inventoryCD`).

 

3. SubstituteKey:  

   Allows users to reference the `InventoryItem.inventoryCD` (a human-readable identifier) instead of the numeric `InventoryID`.

 

4. DescriptionField:  

   Displays the description (`InventoryItem.descr`) in the selector dropdown for user convenience.

 

5. PXUIField:  

   Specifies the label for the field on the user interface.

 

Related Substitute Key Example (InventoryCD):  

The `InventoryCD` field, often used as the user-friendly identifier for inventory items, is declared as:

 

```csharp

#region InventoryCD

[PXDBString(30, IsKey = true, IsUnicode = true)]

[PXDefault]

[PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.SelectorVisible)]

[PXFieldDescription]

public virtual string InventoryCD { get; set; }

public abstract class inventoryCD : PX.Data.BQL.BqlString.Field<inventoryCD> { }

#endregion

```

 

This field (InventoryCD) is typically used as the key to reference inventory items in various forms and reports.

 

 


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

Hi ​@Django, Thanks for the response.

My DAC declaration is as below
 

 public class InventoryItemExtensions : PXCacheExtension<PX.Objects.IN.InventoryItem>
{
#region UsrTI
[PXDBInt]
[PXUIField(DisplayName = "TI")]

public virtual int? UsrTI { get; set; }
public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { }
#endregion

}

I am not calculating the field; I am manually entering random values and want to retrieve them on the Sales Orders screen. I believe that if we are not calculating or defaulting the data in the Stock Items screen, it might be challenging to retrieve the value. Is it possible to fetch a manually entered, non-bound value from the Stock Items screen to the Sales Order Line details?


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

@Django please check my second reply hope it's helpful 

@smuddurthi81 Yes, I checked your response and in those events cusrom field value getting null only, So it is not possible to retrieve the same.


Forum|alt.badge.img
  • Varsity I
  • January 22, 2025

@Nilkanth Dipak 

Check my explanation below!

Yes, the solution I provided earlier is applicable for Acumatica. Here's a summary of how to handle custom unbound fields in Acumatica, with a focus on retrieving values from a related screen like **InventoryItem** to **Sales Orders** (SOLine).

 

### Scenario in Acumatica:

You have custom unbound fields on the **Sales Orders** (SOLine) screen that need to be populated with data from related records (e.g., from the **InventoryItem** DAC). These custom fields are not persisted in the database and only exist temporarily for the duration of the screen session. The goal is to populate them dynamically, based on some related data, such as `InventoryItem`.

 

### Key Steps and Solutions for Acumatica:

 

#### 1. **Use the PXFieldDefaulting Event**:

   The `FieldDefaulting` event is a good place to set values for unbound fields. This event occurs before the field's value is accessed, ensuring it is populated when necessary.

 

   Example for setting a custom field (`UsrCustomField`) from `InventoryItem`:

 

   ```csharp

   protected void SOLine_UsrCustomField_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)

   {

       var row = (SOLine)e.Row;

       if (row == null || row.InventoryID == null) return;

 

       // Fetch the InventoryItem record based on InventoryID

       InventoryItem item = PXSelect<InventoryItem,

           Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>

           .Select(Base, row.InventoryID);

 

       if (item != null)

       {

           // Fetch custom field value from InventoryItem

           InventoryItemExt itemExt = item.GetExtension<InventoryItemExt>();

           e.NewValue = itemExt?.UsrCustomField; // Set the value for the unbound field

       }

   }

   ```

 

#### 2. **Use PXFormula for Dynamic Field Calculation**:

   If the custom field's value depends on a related field (like `InventoryID`), you can use the `PXFormula` attribute to dynamically calculate and display the value. This is useful if the custom field needs to be automatically recalculated when other fields change.

 

   Example of using `PXFormula` to set the value dynamically:

 

   ```csharp

   [PXString]

   [PXFormula(typeof(Selector<SOLine.inventoryID, InventoryItemExt.usrCustomField>))]

   [PXUIField(DisplayName = "Custom Field")]

   public virtual string UsrCustomField { get; set; }

   public abstract class usrCustomField : PX.Data.BQL.BqlString.Field<usrCustomField> { }

   ```

 

   This formula fetches the value from the `InventoryItem` based on the `InventoryID` and displays it in the custom field.

 

#### 3. **Use a Helper Method for Value Retrieval**:

   If you need to fetch custom values programmatically, create a helper method in the graph to retrieve the value from `InventoryItem` and set it in your custom field.

 

   Example helper method to retrieve the custom field value from `InventoryItem`:

 

   ```csharp

   public static string GetCustomFieldValue(int? inventoryID)

   {

       if (inventoryID == null) return null;

 

       InventoryItem item = PXSelect<InventoryItem,

           Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>

           .Select(new PXGraph(), inventoryID);

 

       InventoryItemExt itemExt = item?.GetExtension<InventoryItemExt>();

       return itemExt?.UsrCustomField; // Return custom field value

   }

   ```

 

   Then call this method in your event handlers like `RowSelected` or `FieldUpdated` to set the custom field value.

 

#### 4. **Ensure Unbound Fields Are Updated Properly**:

   Unbound fields are temporary and need to be explicitly set or updated when required. Use the `RowSelected` event or similar to refresh or populate these fields.

 

   Example in `RowSelected` to ensure the custom field is populated:

 

   ```csharp

   protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)

   {

       var row = (SOLine)e.Row;

       if (row == null) return;

 

       SOLineExt rowExt = row.GetExtension<SOLineExt>();

 

       // Check if the custom field is null and populate it

       if (rowExt.UsrCustomField == null)

       {

           rowExt.UsrCustomField = GetCustomFieldValue(row.InventoryID); // Set custom field value

           cache.SetValueExt<SOLineExt.usrCustomField>(row, rowExt.UsrCustomField);

       }

   }

   ```

 

#### 5. **Debugging and Validation**:

   - Ensure that the `InventoryID` value is correctly populated and not null when you are trying to fetch the related values.

   - If values still don't populate, use debugging techniques like logging (`PXTrace`) or breakpoints to ensure the methods are being triggered as expected.

 

---

 

### Summary:

In Acumatica, to properly set custom unbound fields on screens like **Sales Orders**, you should:

- Use `FieldDefaulting` to populate values for unbound fields based on related data (e.g., from `InventoryItem`).

- Use `PXFormula` for dynamic calculation and binding.

- Consider using helper methods to retrieve the necessary values from related DACs like `InventoryItem`.

- Make sure unbound fields are refreshed and updated at the right point in the screen lifecycle (e.g., during `RowSelected`).

 

 


Forum|alt.badge.img+7
  • Captain II
  • January 22, 2025

@smuddurthi81  - copying and pasting AI responses isn’t always helpful.

@Nilkanth Dipak - now I understand. You just want to display the UsrTI field from the InventoryItem DAC on the SOLine for the user to see.

I have a similar requirement on my SOOrderEntry screen.

Using FieldSelecting will ensure that when an existing row is loaded that the value is pulled from the InventoryItem DAC.

protected virtual void _(Events.FieldSelecting<SOLine, SOLineExt.usrYourField> e)
{
SOLine row = (SOLine)e.Row;
if (row != null)
{
if (row.InventoryID != null)
{
if (row.SiteID != null)
{
InventoryItem item = InventoryItem.PK.Find(Base, row.InventoryID);
if (item != null)
{
InventoryItemExt itemExt = item.GetExtension<InventoryItemExt>();
if (itemExt != null)
{
e.ReturnValue = itemExt.UsrYourField;
e.Cancel = true;
}

}
}
}
}
}

BUT:

When you are entering a new row, you need to add logic to call the above routine so that it is populated/refreshed when the InventoryID column value is changed:

protected virtual void _(Events.FieldUpdated<SOLine, SOLine.inventoryID> e, PXFieldUpdated baseMethod)
{

baseMethod?.Invoke(e.Cache, e.Args);

SOLine row = e.Row as SOLine;

SOLineExt rowExt = row.GetExtension<SOLineExt>();

//this line of code will force the calculation of the default
//which will, in turn, call the FieldSelecting event
Base.Caches[typeof(SOLine)].SetDefaultExt<SOLineExt.usrYourField>(row);

...

}

And I believe that your SOLine field declaration will need a [PXDefault()] declaration so that the SetDefaultExt code will trigger.

[PXDefault(0, PersistingCheck = PXPersistingCheck.Nothing)] //There is a _FieldDefaulting event

 


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • January 22, 2025

Hi ​@Django,

Really Appreciate your time on this. I will try and let you know if it works for me.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • January 22, 2025

Hi ​@smuddurthi81 - While using AI to assist with community questions is currently permitted, members are required to note it at the beginning of their reply. Something like "This reply has been created with the help of AI". Thank you!

Using AI to assist with creating community replies


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • Answer
  • January 26, 2025

@Django 

I tried using the FieldSelecting event to retrieve values from custom fields, but I encountered an issue where the values were coming in as `null`.  

 

After discussing with the client, it was confirmed that saving the data directly in the InventoryItem DAC is necessary to ensure the values are available when needed. The client agreed to this approach.  

 

To achieve this, I utilized the PXFormula attribute in DAC level to automatically populate the required fields by comparing the `InventoryID` from the SOLine DAC. With this approach, the correct data entered in the Stock Item screen is now successfully passed for the respective stock item.  

 

This solution has resolved the issue and ensures the expected values are properly carried over.

Thanks for the suggestions.