Question

Customized selector Attribute is not Sorting Correctly


Userlevel 4
Badge

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


3 replies

Userlevel 4
Badge

Hi @ramya15,

I am not sure but I believe you need to change the order of fields from CustomTaxCategoryOrderByAttribute.

[CustomTaxCategoryOrderBy(typeof(TaxCategory.taxCategoryID),typeof(TaxCategory.descr),typeof(TaxCategoryExt.usrSerialNo))]

 

Userlevel 4
Badge

Hi @Dipak Nilkanth,

Yes, i tried to change the Order of the fields as you mentioned. But it is sort using the “TaxCatgoryID”.

[CustomTaxCategoryOrderBy(typeof(TaxCategory.taxCategoryID),typeof(TaxCategory.descr),typeof(TaxCategoryExt.usrSerialNo))]

Not sure why it is working in this way. I tired to debug the “GetRecords”. It returns the correct result, but in the selector alone if i change the Order as you mentioned then it sort using TaxCategoryID.

 

[CustomTaxCategoryOrderBy(typeof(TaxCategorySort.usrSerialNo), typeof(TaxCategorySort.taxCategoryID), typeof(TaxCategorySort.descr))]

If i provide like this, then only it sorts based on serial number, but the selector pass serial No. instead of TaxCategory ID.

Please help me to check on this.

Userlevel 4
Badge

Hi Team,

Anyone i have idea on this. I tried SQL view, Projection DAC but nothing works out.

 

Regards,

Ramya

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