Solved

Calendar Preferences/ Board andding default staff

  • 17 January 2023
  • 9 replies
  • 252 views

Userlevel 2
Badge

Hi Community!,

I’m trying to add deault staff names to calendar Board from Service Orders  default staff tab , I’m unabel to find a way to add FSSOEmployee DAC to the list is there any specific way or process to add it.

 


 

 

icon

Best answer by Yuriy Zaletskyy 25 January 2023, 23:11

View original

9 replies

Userlevel 5
Badge +3

In Acumatica, you can add the FSSOEmployee DAC to the calendar board by creating a custom graph extension and modifying the calendar board's data source.

Here is an example of how you can do it:

  1. Create a new class that inherits from PXGraphExtension<FSServiceOrderEntry>. This class will be used to add the FSSOEmployee DAC to the calendar board.

public class FSServiceOrderEntry_Extension : PXGraphExtension<FSServiceOrderEntry>

{

        // Your code here

}

  1. Override the Initialize() method in the custom graph extension class, and use the PXSelectJoin to join the FSSOEmployee DAC with the FSServiceOrder DAC.

public override void Initialize()
    {
        base.Initialize();

        // Use PXSelectJoin to join the FSSOEmployee DAC with the FSServiceOrder DAC

        PXSelectJoin<FSServiceOrder, LeftJoin<FSSOEmployee, On<FSSOEmployee.employeeID,               Equal<FSServiceOrder.defaultEmployeeID>>>, Where<FSServiceOrder.status,  NotEqual<FSServiceOrder.status.Cancelled>>> CalendarView;

       // Assign the CalendarView to the CalendarBoard

       Base.CalendarBoard.SetDataSource(CalendarView);

}

 

  1. In the FSServiceOrderEntry.aspx, you need to add the CalendarBoard, add the following code to the aspx file

<px:PXGrid runat="server" ID="CalendarBoard" DataSourceID="ds" Width="100%" Height="100%" AllowSearch="True" AllowAutoSort="True" Style="z-index: 100"></px:PXGrid>

Also, you need to make sure that the FSSOEmployee DAC is correctly defined and registered in the Acumatica's system.

In summary, to add the FSSOEmployee DAC to the calendar board in Acumatica, you need to create a custom graph extension for FSServiceOrderEntry and use PXSelectJoin to join the FSSOEmployee DAC with the FSServiceOrder DAC, and then assign the CalendarView to the CalendarBoard. You also need to make sure that the FSSOEmployee DAC is correctly defined and registered in the Acumatica's system.

Userlevel 2
Badge

hey @Yuriy Zaletskyy thank you for replying i have tried the code you have provided, but there is issue with 2nd and 3rd point.
when I try to add the code it is throiwng error.


I’m not sure how to add the 3rd point I tried adding it Aspx changes but they are not reflecting in the screen.
I hope this is correct Aspx
 

 

 

Userlevel 5
Badge +3

Tell me please, which Acumatica version you have?

Userlevel 2
Badge

Sure @Yuriy Zaletskyy  it’s Acumatica ERP 2021 R2
Build 21.219.0019

Userlevel 5
Badge +3

I see your issue. Please see below:

The list is filled with DACs in the ComponentFieldRowSelect method of the PX.Objects.FS.CalendarComponentSetupMaint.1. Create a CalendarComponentSetupMaintExt extension graph, override the ComponentFieldRowSelect method in it.
2. In the overlapped method, call the base method first, and then add the desired DAC to the list in the same way as in the original graph.

 public delegate void ComponentFieldRowSelectDelegate(PXCache cache, FSCalendarComponentField row, Type objectName, Type field, Boolean isServiceOrder);
[PXOverride].
public void ComponentFieldRowSelect(PXCache cache, FSCalendarComponentField row, Type objectName, Type field, Boolean isServiceOrder, ComponentFieldRowSelectDelegate baseMethod)
{
baseMethod(cache, row, objectName, field, isServiceOrder);
List<string> aliases = new List<string>();
List<string> dlabels = new List<string>();
Aliases.Add(typeof(FSSOEmployee).FullName);
dlabels.Add(typeof(FSSOEmployee).Name);
PXStringListAttribute.AppendList(cache, row, objectName.Name, aliases.ToArray(), dlabels.ToArray());
}
PXStringListAttribute.SetList() method - need to replace with PXStringListAttribute.AppendList(), so as not to delete the original list of DACs.

and full code:

 

using PX.Data;
using PX.Data.BQL;
using PX.Objects;
using PX.Objects.FS;
using System;
using System.Collections.Generic;

namespace Calendar
{
public class CalendarComponentSetupMaint_Extension : PXGraphExtension<CalendarComponentSetupMaint>
{
public static bool IsActive() => true;

public delegate void ComponentFieldRowSelectDelegate(PXCache cache, FSCalendarComponentField row, Type objectName, Type field, Boolean isServiceOrder);
[PXOverride]
public void ComponentFieldRowSelect(PXCache cache, FSCalendarComponentField row, Type objectName, Type field, Boolean isServiceOrder, ComponentFieldRowSelectDelegate baseMethod)
{
baseMethod(cache, row, objectName, field, isServiceOrder);

List<string> aliases = new List<string>();
List<string> dlabels = new List<string>();

aliases.Add(typeof(FSSOEmployee).FullName);
dlabels.Add(typeof(FSSOEmployee).Name);

PXStringListAttribute.AppendList(cache, row, objectName.Name, aliases.ToArray(), dlabels.ToArray());

}


//public override void Initialize()
//{

// // Use PXSelectJoin to join the FSSOEmployee DAC with the FSServiceOrder DAC
// base.Initialize();

// PXSelectJoin<FSServiceOrder, LeftJoin<FSSOEmployee, On<FSSOEmployee.sOID, Equal<FSServiceOrder.sOID>>>,
// Where<FSServiceOrder.status, NotEqual<FSServiceOrder.status.Values.canceled>>> CalendarView;


// var result = PXSelectJoin < FSServiceOrder, LeftJoin< FSSOEmployee, On < FSSOEmployee.sOID, Equal < FSServiceOrder.sOID >>>,
// Where < FSServiceOrder.status, NotEqual < FSServiceOrder.status.Values.canceled >>>.Select(Base);



// // Assign the CalendarView to the CalendarBoard

// //Base.ServiceOrderFields = CalendarView;

//}
}
}

commented code left as demonstration of thought research process

Badge

@Yuriy Zaletskyy Thanks for your response, replying on behalf of Dinesh (Author). The code works fine and does add the new DAC mentioned. But still there is a missing link in what we are trying to achieve.

We want to display the Staff Member Name (BAccount.AcctName) in the calendar board. With the code, that you shown in your reply, it does add the FSSOEmployee but if I add the BAccount in dropdown, the calendar board does not show any data. The FSSOEmployee is the link between FSServiceOrder and BAccount.

The following is the BQL that gives us the Staff Member Names:

var baresult = PXSelectJoin<BAccount, LeftJoin<FSSOEmployee, On<BAccount.bAccountID, Equal<FSSOEmployee.employeeID>>,
LeftJoin<FSServiceOrder, On<FSSOEmployee.sOID, Equal<FSServiceOrder.sOID>>>>,
Where<FSServiceOrder.refNbr, Equal<Required<FSServiceOrder.refNbr>>>>
.Select(Base, row.RefNbr);

So, our end goal is to display the Staff Member Name (from Default staff tab in Service Order).

I tried another approach of adding a column in the FSServiceOrder table itself and filling it with comma separated staff member names. The new column has the data now, but still it is not displayed in the calendar board. Attaching screenshots below. Happy to have it working either way.

 

 

 

 

Userlevel 5
Badge +3

I found the following solution:
1)Create a dac extenction for FSServiceOrder
2) Add a custom field and by applying the PxFormula attribute get the required data from the required tables.The new field can now be selected in Calendar Preferences
and it will appear in the Calendar Board.

 

 

using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data.WorkflowAPI;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CM.Extensions;
using PX.Objects.CR.MassProcess;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.FS;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.TX;
using PX.Objects;
using System.Collections.Generic;
using System;
namespace PX.Objects.FS
{
public class FSServiceOrderExt : PXCacheExtension<PX.Objects.FS.FSServiceOrder>
{
[PXInt]
[PXUIField(DisplayName = "EmployeeId", IsReadOnly = true)]
[PXParent(typeof(Select<FSSOEmployee,
Where<FSSOEmployee.sOID, Equal<Current<FSServiceOrder.sOID>>>>))]
[PXFormula(typeof(Parent<FSSOEmployee.employeeID>))]
public virtual int? EmployeeId{ get; set; }
public abstract class employeeId: PX.Data.BQL.BqlString.Field<employeeId> { }
[PXString]
[PXUIField(DisplayName = "Staff Name", IsReadOnly = true)]
[PXParent(typeof(Select<BAccount,
Where<BAccount.bAccountID, Equal<Current<employeeId>>>>))]
[PXFormula(typeof(Parent<BAccount.acctName>))]
public virtual string StaffName{ get; set; }
public abstract class staffName: PX.Data.BQL.BqlString.Field<staffName> { }
}
}

 

Badge

@Yuriy Zaletskyy Appreciate your help on this. The code you provided above does show the default staff member name. But there is one last thing which is pending, if there is multiple default staff member in the service order, it display only one name. I tried searching internet if I could find a way to achieve this but I could not find anything. I would expect to display comma separated default staff names, if there are multiple or if there is any other way like calendar board shows 2 records if there are 2 default staff in the service order. Thanks very much.

Here is a snippet how I could do it in a C# method, I don't know how to convert it to BQL and assign in the DAC property:

var baresult = PXSelectJoin<BAccount, LeftJoin<FSSOEmployee, On<BAccount.bAccountID, Equal<FSSOEmployee.employeeID>>,
LeftJoin<FSServiceOrder, On<FSSOEmployee.sOID, Equal<FSServiceOrder.sOID>>>>,
Where<FSServiceOrder.refNbr, Equal<Required<FSServiceOrder.refNbr>>>>
.Select(Base, row.RefNbr);
List<string> acctNames = new List<string>();
if (baresult != null)
{
foreach (BAccount res in baresult)
{
acctNames.Add(res.AcctName);
}
}
if (acctNames.Count > 0)
{
e.ReturnValue = string.Join(", ", acctNames);
}

 

Userlevel 5
Badge +3

I would suggest to open new thread, as it seems separate issue, not related to original one in description 

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