Good day
I have created a custom attribute for the customer ID attribute on Sales orders. With the current attributes on the Customer ID customers that are in credit hold are not shown in the list.
My idea is to change the list dynamically so that if the order type is QT customers that are in credit hold still show in the list.
My problem is I don't know if there is a way to send/get the current SOOrder.OrderType
Here is where I am at
namespace PX.Objects.SO
{
[PXNonInstantiatedExtension]
public class SO_SOOrder_ExistingColumn : PXCacheExtension<PX.Objects.SO.SOOrder>
{
#region CustomerID
[PXMergeAttributes(Method = MergeMethod.Append)]
// [CustomercustomersAttribute(Current<SOOrder.orderType>))]
[CustomercustomersAttribute()]
public int? CustomerID { get; set; }
#endregion
}
public class CustomercustomersAttribute : PXCustomSelectorAttribute
{
public string orderType { get; set; }
public Type orderType2 { get; set; }
public CustomercustomersAttribute(Type OrderType) : base(typeof(Customer.acctCD))
{
this.orderType2 = OrderType;
this.DescriptionField = typeof(Customer.acctName);
}
public CustomercustomersAttribute(string OrderType) : base(typeof(Customer.acctCD))
{
this.orderType = OrderType;
this.DescriptionField = typeof(Customer.acctName);
}
public CustomercustomersAttribute() : base(typeof(Customer.acctCD))
{
this.DescriptionField = typeof(Customer.acctName);
}
protected virtual IEnumerable GetRecords()
{
foreach (Customer pc in PXSelect<Customer>.Select(this._Graph))
{
if (pc.Status != "A")
{
// Here I want to do the check if
if (orderType.ToString() == "QT")
{
yield return pc;
}
}
else
{
yield return pc;
}
}
}
}
}
Try obtaining the current cache object from Graph Caches
collection:
Type fieldType = [...];
var cache = _Graph.Caches[BqlCommand.GetItemType(fieldType)];
var currentCacheObject = cache.Current;