Question

The header value doesn't automatically update.


Userlevel 3
Badge

This is an extension of a thread:

 How can I change header value of a field based on currently selected row in the grid.

So far, I have found a working solution. However, there's a minor issue: the UsrWorkCenterID field (show details...) doesn't update automatically. I need to clear the current record to obtain the new value. If anyone knows how to resolve this minor issue, please share the solution.

 

protected void AMProdItem_UsrWorkCenterID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
// Getting the production item data.
var prodItemRow = (AMProdItem)e.Row;
if (prodItemRow == null) return; // If there's no data, return.

// Trying to find the current operation info.
var currentOperRow = Base.Caches<AMProdOper>().Current as AMProdOper;

// If the current operation matches the item's details, use its Work Center ID.
if (currentOperRow != null && currentOperRow.ProdOrdID == prodItemRow.ProdOrdID)
{
e.ReturnValue = currentOperRow.WcID;
}
else
{
// If not, look for related operations to find a Work Center ID.
var relatedOper = PXSelect<AMProdOper,
Where<AMProdOper.orderType, Equal<Required<AMProdOper.orderType>>,
And<AMProdOper.prodOrdID, Equal<Required<AMProdOper.prodOrdID>>>>
>.SelectWindowed(Base, 0, 1, prodItemRow.OrderType, prodItemRow.ProdOrdID);

// If a related operation is found, set the return value to its Work Center ID.
if (relatedOper != null && relatedOper.Count > 0)
{
e.ReturnValue = ((AMProdOper)relatedOper).WcID;
}
}
}
#region UsrWorkCenterID
[PXString(20)]
[PXSelector(typeof(Search<AMProdOper.wcID,
Where<AMProdOper.orderType, Equal<Current<AMProdItem.orderType>>,
And<AMProdOper.prodOrdID, Equal<Current<AMProdItem.prodOrdID>>>>>))]
[PXUIField(DisplayName = "Show Details For Work Center")]

public virtual string UsrWorkCenterID { get; set; }
public abstract class usrWorkCenterID : PX.Data.BQL.BqlString.Field<usrWorkCenterID> { }

 


10 replies

Userlevel 5
Badge +3

I believe you missing RepaintControlID and commit changes, which should be set on .aspx files as shown below:

 

 

Userlevel 3
Badge

Thanks, by the way. What should be included in 'RepaintControlIDs' and 'PostData'? Are there any documentation or blog posts available? I'm just touching on these areas for the first time

 

Userlevel 7
Badge +4

Hi @rashmikamudalinayake10,

Few things to consider,

  1. User RowSelected(AMProdMatlSplit_RowSelected) event of the grid, because FieldSelecting might seem right but what if the Select failed. Usually RowSelected is used to update/refresh the UI controls.
  2. User Base.ProdItemRecords.View.RequestRefresh() to refresh the UI once the row is selected and the field value is updated.

If you have further questions, please feel free to share the sample customization using which we could reproduce the issue. Good Luck,

Userlevel 3
Badge

Yet, I couldn’t find a solution, and AMProdMatlSplit_RowSelected was unable to sort it out. If anyone could help with this, it would be great. I have attached the zip file

Userlevel 3
Badge

@Naveen Boga could you help here if you know.

Userlevel 7
Badge +4

Hey @rashmikamudalinayake10,

Thanks for sharing the customization package.

Sorry, I couldn’t get back to earlier. In this case, ideally you can use the AMProdOper_RowSelected in the graph extension of PX.Objects.AM.ProdDetail.  tried the following to set the selector value for the custom field and refresh the screen but for some reason the UI doesn’t reflect the value set from the graph extension. 

	public class ProdDetail_Extension : PXGraphExtension<PX.Objects.AM.ProdDetail>
{
#region Event Handlers
public static bool IsActive()
{
return true;
}

protected void AMProdOper_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
{
baseHandler?.Invoke(cache, e);
var row = (AMProdOper)e.Row;
AMProdItem prodItem = Base.ProdItemRecords.Current;
AMProdItemExt prodItemExt = prodItem.GetExtension<AMProdItemExt>();
if (row == null || row.WcID == null) return;
prodItemExt.UsrWorkCenterID = row.WcID;
Base.ProdItemRecords.View.RequestRefresh();
}

I couldn’t narrow down to what could cause this behavior. I would recommend you create a Dev support ticket and we can look into it. Thanks, 

 

Userlevel 3
Badge

How to create a Dev support ticket?

Userlevel 7
Badge +4

Please create the case using the Acumatica portal: https://portal.acumatica.com/

 

Userlevel 3
Badge

Created. Looking forward for a reply

Userlevel 2
Badge

Based on the understanding of the requirement, you are trying to update the Master object based on the Detail object selection. In this case, you are trying to set value to the custom field in the AMProdItem (Master) based on the selection of the grid – AMProdOper (Detail). If you don’t want to persist the value and just set the value in the UI alone, it would be okay but persisting would not be a good idea.

 

Kindly create a new view with your custom field in the Header side and set the view and use the same approach to set the custom field in the newly created view. This is similar to the approach of how Materials (AMProdMatl) grid gets updated based on the change of Operations (AMProdOper) grid.

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