Hello,
I’m currently trying to execute an action where when the button is pushed, it will look at the current employee selected on the service appointment, go to that employee (where the default workgroup id exists), and then once that record is found, I use the defaultworkgroupid to pass into a second pxselect to find all employees that share the same default workgroup. I then run the foreach loop to add them to the appointment.
However, I am getting an error (see below) where the type is not correct. I have a feeling that I need to run a join on my select but I’m not entirely sure how to go about it.
{
#region Views
public PXSelect<EPEmployee, Where<EPEmployee.bAccountID, Equal<Current<FSAppointmentEmployee.employeeID>>>> EmpLead;
#endregion
#region Actions
public PXAction<FSAppointmentEmployee> AddCrew;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Add Crew", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
protected void addCrew()
{
//EPEmployee lead = PXSelect<EPEmployee, Where <EPEmployee.bAccountID, Equal<Current<FSAppointmentEmployee.employeeID>>>>.Select(Base);
EPEmployee lead = EmpLead.Current as EPEmployee;
foreach (PXResult<EPEmployee> crew in PXSelect<EPEmployee, Where<EPEmployee.defaultWorkgroupID, Equal<lead.DefaultWorkgroupID>>>.Select(Base))
{
EPEmployee employee = crew;
FSAppointmentEmployee newCrew = new FSAppointmentEmployee();
newCrew.EmployeeID = employee.BAccountID;
Base.AppointmentServiceEmployees.Insert(newCrew);
}
}
}
Best answer by Shawn Burt
View original