Hi Team,
I have created a Custom Attribute to sort using serial number for the Tax Category selector. Sorting is working as expected, but instead of Passing the Tax categoryID, it is passing the serial number from the selector as value to UI, when i do the selection.
Please help me on this.
public class CATranEntry_Extension : PXGraphExtension<PX.Objects.CA.CATranEntry>
{
public PXSelect<TaxCategory, Where<TaxCategory.active, Equal<True>>,
OrderBy<Asc<TaxCategoryExt.usrSerialNo>>> MySelectorView;
#region Event Handlers
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXDBString(TaxCategory.taxCategoryID.Length, IsUnicode = true)]
[PXUIField(DisplayName = "Tax Category", Visibility = PXUIVisibility.Visible)]
[CATax(typeof(CAAdj), typeof(CATax), typeof(CATaxTran), typeof(CAAdj.taxCalcMode), parentBranchIDField: typeof(CAAdj.branchID),
CuryOrigDocAmt = typeof(CAAdj.curyControlAmt), DocCuryTaxAmt = typeof(CAAdj.curyTaxAmt))]
[CustomTaxCategoryOrderBy(typeof(TaxCategoryExt.usrSerialNo),typeof(TaxCategory.taxCategoryID), typeof(TaxCategory.descr))]
[PXDefault(typeof(Search<InventoryItem.taxCategoryID,
Where<InventoryItem.inventoryID, Equal<Current<CASplit.inventoryID>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]
protected virtual void CASplit_TaxCategoryID_CacheAttached(PXCache cache)
{
}
#endregion
}
internal class CustomTaxCategoryOrderByAttribute : PXCustomSelectorAttribute
{
public CustomTaxCategoryOrderByAttribute(Type searchType, params Type[] fieldList)
: base(searchType, fieldList)
{
}
protected virtual IEnumerable GetRecords()
{
BqlCommand select = BqlCommand.CreateInstance(typeof(
Search<TaxCategory.taxCategoryID,
Where<TaxCategory.active, Equal<True>>>));
// BqlCommand orderBy = BqlCommand.CreateInstance(typeof(OrderBy<Asc<TaxCategoryExt.usrSerialNo>>));
select = select
.WhereAnd<Where<TaxCategory.active, Equal<True>>>()
.OrderByNew<OrderBy<
Asc<TaxCategoryExt.usrSerialNo,
Asc<TaxCategory.taxCategoryID>>>>();
PXGraph graph = _Graph;
PXView view = new PXView(graph, true, select);
List<object> result = view.SelectMulti();
List<TaxCategory> typedResult = new List<TaxCategory>();
foreach (var item in result)
{
typedResult.Add(item as TaxCategory);
}
return typedResult;
}
}


Regards,
Ramya