To Fetch Calculated Data from a Non-Scalar Source (in RowSelecting)
The following activity will walk you through the process of fetching calculated data from a non-scalar source by using the RowSelecting event handler.
Story
Suppose that you need to fetch the values for the Number of Assigned Work
                    Orders column, which is displayed on the Assign Work Orders
                (RS501000) form. (You have developed this form for the Smart Fix company.) You need to write a fluent BQL query that fetches the number of
                assigned work orders from the RSSVEmployeeWorkOrderQty DAC for the
                employee selected in the AssignTo field of the
                    RSSVWorkOrder DAC.
Process Overview
To fetch the needed values, you will use the RowSelecting event
                handler. In the event handler, you will retrieve the number of assigned work orders
                for the employee selected in the AssignTo field of the
                    RSSVWorkOrder DAC.
System Preparation
Before you begin defining the logic for fetching data from a non-scalar source, do the following:
- Prepare an MYOB Acumatica instance by performing the Test Instance for Customization: To Deploy an Instance with a Custom Form that Implements a Workflow prerequisite activity.
 - Create a processing form without filtering parameters by performing the Processing Forms: To Create a Simple Processing Form prerequisite activity.
 
Step 1: Extending the RSSVWorkOrder DAC
RSSVWorkOrder DAC as follows:- Define the 
NbrOfAssignedOrdersfield, as the following code shows.#region NbrOfAssignedOrders [PXInt] [PXUIField(DisplayName = "Number of Assigned Work Orders")] public virtual int? NbrOfAssignedOrders { get; set; } public abstract class nbrOfAssignedOrders : PX.Data.BQL.BqlInt.Field<nbrOfAssignedOrders> { } #endregion - Build the project.
 
Step 2: Fetching Values for the NbrOfAssignedOrders Field
RSSVAssignProcess graph as follows:- In the RSSVAssignProcess.cs file, add the
                            
PX.Data.BQLusingdirective. - In the graph, define the following RowSelecting event
                        handler.
protected virtual void _(Events.RowSelecting<RSSVWorkOrder> e) { using (new PXConnectionScope()) { if (e.Row == null) return; RSSVEmployeeWorkOrderQty employeeNbrOfOrders = SelectFrom<RSSVEmployeeWorkOrderQty>. Where<RSSVEmployeeWorkOrderQty.userID.IsEqual<@P.AsInt>>. View.Select(this, e.Row.AssignTo); if (employeeNbrOfOrders != null) { e.Row.NbrOfAssignedOrders = employeeNbrOfOrders.NbrOfAssignedOrders.GetValueOrDefault(); } else { e.Row.NbrOfAssignedOrders = 0; } } } - Build the project.
 
