Skip to main content
Answer

Access Attribute of one DAC into another

  • April 24, 2025
  • 2 replies
  • 53 views


I need to check the checkbox Allocation Apply which is a User-Defined Attribute in SOOrder  when ever there is any change in the orderQuantity.

I also want to disable the Allocation Apply Field
public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
  {

protected void _(Events.FieldUpdating<SOLine, SOLine.orderQty> e)
{

var row = e.Row;

// Need to udpate the Apply field when ever there any change in the OrderQty 

// Allocation Apply field is in SOOrder

}



// The below Solution isn’t working

 SOOrder Order = PXSelect<SOOrder, Where<
                             SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>
                                 >
                   >.Select(Base, row.OrderNbr);
var isAllcocateed = e.Cache.GetValueExt(Order, "AttributeALLOCAPPLY");

Best answer by DipakNilkanth

Hi ​@anupusefulbi,

Try below code snippet.

protected void _(Events.FieldUpdated<SOLine, SOLine.orderQty> e)
{
if (e.Row == null)
return;

var order = Base.Document.Current;
if (order != null)
{
PXCache orderCache = Base.Document.Cache;

orderCache.SetValueExt(order, "AttributeALLOCAPPLY", true);
orderCache.MarkUpdated(order);
}
}

protected void _(Events.RowSelected<SOOrder> e)
{
if (e.Row == null)
return;

PXUIFieldAttribute.SetEnabled(e.Cache, e.Row, "AttributeALLOCAPPLY", false);
}
}

Hope, it helps!

2 replies

Forum|alt.badge.img+1
  • Jr Varsity I
  • April 24, 2025

If you are trying to set the value of this attribute, you may want to use something like Base.Document.Cache.SetValueExt(...)

If you want to disable the attribute, you can either do it in the workflow, or try it in rowselected event handler using something like PXUIFieldAttribute.SetEnabled(...)

 

Let me know if that helps.


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Pro III
  • Answer
  • April 24, 2025

Hi ​@anupusefulbi,

Try below code snippet.

protected void _(Events.FieldUpdated<SOLine, SOLine.orderQty> e)
{
if (e.Row == null)
return;

var order = Base.Document.Current;
if (order != null)
{
PXCache orderCache = Base.Document.Cache;

orderCache.SetValueExt(order, "AttributeALLOCAPPLY", true);
orderCache.MarkUpdated(order);
}
}

protected void _(Events.RowSelected<SOOrder> e)
{
if (e.Row == null)
return;

PXUIFieldAttribute.SetEnabled(e.Cache, e.Row, "AttributeALLOCAPPLY", false);
}
}

Hope, it helps!