Skip to main content

I have a custom selector created in the sales order line as below, which is a selector that filters the values from a custom table based on the UOM selected on the sales order line. (UOM selected filters the corresponding matching WeightUOM field in the custom table and displays selector values)

[PXDBString(500, IsUnicode = true)]
[PXSelector(
typeof(Search<MWTPackagingOptions.packageDescription>),
typeof(MWTPackagingOptions.packageDescription),
typeof(MWTPackagingOptions.weightUOM),
DescriptionField = typeof(MWTPackagingOptions.packageDescription)
)]
[PXRestrictor(
typeof(Where<MWTPackagingOptions.weightUOM, Equal<Current<SOLine.uOM>>>),
"The selected packaging option is not valid for the UOM on this sales order line."
)]
[PXUIField(DisplayName = "Package Type")]

This works but if I update the UOM how can I ensure the selector is automatically refreshed without having to manually click the refresh button in the selector to extract the results? I have tried a fieldupdated for UOM but it does not do any changes.

    protected void SOLine_UOM_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
// Invoke the base handler if it exists (this is equivalent to calling base.<EventMethod> in other cases)
InvokeBaseHandler?.Invoke(cache, e);

SOLine row = (SOLine)e.Row;

if (row != null)
{
// Custom logic after the base handler
cache.SetValueExt<SOLineExt.usrCustomPackageType>(row, null);

// Force re-fetch of data in selector
cache.RaiseFieldUpdated<SOLineExt.usrCustomPackageType>(row, null);
}
}

Any help would be appreciated, thank you!

I’ve updated the field logic to be more concise as shown below,

"PXDBString(500, IsUnicode = true)]
/PXSelector(
typeof(Search<MWTPackagingOptions.packageDescription,
Where<MWTPackagingOptions.weightUOM, Equal<Current<SOLine.uOM>>>>),
typeof(MWTPackagingOptions.packageDescription),
typeof(MWTPackagingOptions.weightUOM),
SubstituteKey = typeof(MWTPackagingOptions.packageDescription),
DescriptionField = typeof(MWTPackagingOptions.packageDescription)
)]
/PXUIField(DisplayName = "Package Type")]

 


There is an AutoRefresh properly you can access for the screen control. Set that to True.


Thanks @Django I tried this approach and it worked!


Reply