acumaticaacumatica-kb

How can I use multiple DAC fields in a PXProcessingJoin result?


I have a custom processing screen with its data view (using a PXProcessingJoin) selecting from / joining multiple DACs. Here's an example:

public PXProcessingJoin<GLHistoryByPeriod,
                            InnerJoin<Account,
                                On<GLHistoryByPeriod.accountID, Equal<Account.accountID>>,
                            InnerJoin<Sub,
                                On<GLHistoryByPeriod.subID, Equal<Sub.subID>>,
                            InnerJoin<Branch,
                                On<GLHistoryByPeriod.branchID, Equal<Branch.branchID>>,
                            LeftJoin<GLHistory, On<GLHistoryByPeriod.ledgerID, Equal<GLHistory.ledgerID>,
                                                And<GLHistoryByPeriod.accountID, Equal<GLHistory.accountID>,
                                                And<GLHistoryByPeriod.subID, Equal<GLHistory.subID>,
                                                And<GLHistoryByPeriod.finPeriodID, Equal<GLHistory.finPeriodID>,
                                                And<GLHistoryByPeriod.branchID, Equal<GLHistory.branchID>>>>>>,
                            InnerJoin<MasterFinPeriod, On<GLHistoryByPeriod.finPeriodID, Equal<MasterFinPeriod.finPeriodID>>>>>>>,
                            Where<GLHistoryByPeriod.finPeriodID, Equal<Constants.finPeriod>,
                                And<GLHistory.finYtdBalance, Equal<Constants.finYTDBalance>>>> FileData;

and here's the constructor:

public BlackLineFileMaint()
{
    FileData.SetProcessCaption("Process");
    FileData.SetProcessVisible(true);
    FileData.SetProcessAllCaption("Process All");
    FileData.SetProcessAllVisible(true);
    FileData.SetSelected<BlackLineFileData.selected>();
    FileData.SetProcessDelegate(GenerateFiles);
}

The problem I have is, in the process delegate (here called 'GenerateFiles'):

public static void GenerateFiles(List<GLHistoryByPeriod> records)
{
     //...code goes here - but I need more than the GLHistoryByPeriod fields..
}

How can I get the values of any of / all the other DAC fields in the PXProcessingJoin select? Is there some other way of creating the delegate that adds the other DACs?

Thanks much..


Solution

  • You can pass the entire resultset to your delegate. Sorry, I didn't use your view, but I think you can use this as a template:

    public class TestProcessing : PXGraph<TestProcessing>, IGraphWithInitialization
    {
        public SelectFrom<SOOrder>
            .InnerJoin<Customer>.On<SOOrder.customerID.IsEqual<Customer.bAccountID>>
            .ProcessingView ProcessingView;
    
        // It is called when you press the process button
        public void Initialize()
        {
            // Filter by selected records
            var dataFromView = ProcessingView.Select()
                .Where(it => it.GetItem<SOOrder>().Selected == true)
                .ToList();
        
            ProcessingView.SetProcessDelegate(list => DoProcess(list, dataFromView));
        }
    
        protected static void DoProcess(List<SOOrder> list, List<PXResult<SOOrder>> dataFromView)
        {
            foreach (var data in dataFromView)
            {
                var soOrder = data.GetItem<SOOrder>();
                var soLine = data.GetItem<Customer>();
            }    
        }
    }