BOmosura
BOmosura

Reputation: 53

PXProcessing SetError not showing in UI Grid

This my process screen: enter image description here as you can see it throws errors but it doesnt indicate the error mark on the grid. After clicking the process button, it just unchecks the checkbox in my records

i want the grid to be like this(with the red 'x' mark):

enter image description here

this is my graph :

public PXCancel<PayrollFilter> Cancel;

    public PXSetup<PayrollSetup> PayrollSetup;

    public PXFilter<PayrollFilter> Filter;

    [PXFilterable]
    public PXFilteredProcessingJoin<PayrollEmployeeProcess, PayrollFilter,
                                InnerJoin<EPEmployee,
                                    On<PayrollEmployee.employeeID, Equal<EPEmployee.bAccountID>>,
                                InnerJoin<Branch,
                                     On<EPEmployee.parentBAccountID, Equal<Branch.bAccountID>>>>,
                                Where<PayrollEmployee.payPeriodID, Equal<Current<PayrollFilter.payPeriodID>>,
                                And<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>> EmployeePayrollProcess;



    #region Constructor
    public PayrollProcess()
    {
        PayrollSetup setup = PayrollSetup.Current;

        EmployeePayrollProcess.SetSelected<PayrollEmployeeProcess.selected>();

        EmployeePayrollProcess.SetProcessDelegate(delegate (List<PayrollEmployeeProcess> employees)
        {
            if (Filter.Current == null) return;

            var payPeriod = Filter.Current.PayPeriodID ?? 0;
            var payrollPeriod = Filter.Current.PayrollPeriodID ?? 0;

            if (payPeriod == 0 || payrollPeriod == 0) return;

            PXLongOperation.StartOperation(this, delegate ()
            {
                bool errorOccured = false;
                foreach (PayrollEmployeeProcess employee in employees)
                {

                    PayrollRegisterEntry graph = PXGraph.CreateInstance<PayrollRegisterEntry>();
                    try
                    {

                        graph.ProcessPayroll(employee, payPeriod, payrollPeriod);
                        PXProcessing<PayrollEmployeeProcess>.SetInfo("Employee processed");

                    }
                    catch (Exception ex)
                    {
                        errorOccured = true;
                        //employees.IndexOf(employee), 
                        PXProcessing<PayrollEmployeeProcess>.SetError(ex);
                    }
                    finally
                    {
                        graph.Clear();
                    }
                }
                if (errorOccured) throw new PXException("At least one employee was not processed.");
            });

        });
        // EmployeePayrollProcess.
    }`

can anyone can help me? I'm using Acumatica 6

Upvotes: 0

Views: 863

Answers (1)

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8288

Throwing an exception in Acumatica sets the error in the header. To set a Row or Field level error you need to set/raise it. There's a few ways to set/raise errors, what they have in common is that they don't use the 'throw' keyword.

For a processing screen with a filter, use the following syntax to raise the error:

PXFilteredProcessing<GridDetailDAC, GridFilterDAC>.SetError(rowIndex, new PXSetPropertyException("Error Message", PXErrorLevel.RowError));

Processing screen without filter:

PXProcessing.SetError(rowIndex, new PXException("Error Message"));

Upvotes: 1

Related Questions