Hi @sakthi61.
You won’t be able to add approval to Equipments using PXCacheExtension
.
EPApprovalAutomation
expects type implementing IAssign
and IBqlTable
interfaces. With PXCacheExtension
, your EPEquipmentDCExt
implements IAssign
but not IBqlTable
. EPEquipment
implements IBqlTable
but not IAssign
.
I’d suggest trying with child class of EPEquipment
:
using PX.Data;
using PX.Data.BQL;
using PX.Data.EP;
using PX.Objects.CR.MassProcess;
using PX.Objects.EP;
using PX.TM;
namespace Sprinterra.ApprovalHowTo
{
[PXCacheName("Approvable Equipment")]
public sealed class DCApprovableEPEquipment : EPEquipment, IAssign
{
#region Approved
[PXDBBool]
[PXUIField(DisplayName = "Approve", Visibility = PXUIVisibility.Visible)]
[PXDefault(false)]
public bool? Approved { get; set; }
public abstract class approved : BqlBool.Field<approved> { }
#endregion
#region Rejected
[PXDBBool]
public bool? Rejected { get; set; }
public abstract class rejected : BqlBool.Field<rejected> { }
#endregion
#region Hold
[PXDBBool()]
[PXUIField(DisplayName = "Hold", Visibility = PXUIVisibility.Visible)]
[PXDefault(true)]
public bool? Hold { get; set; }
public abstract class hold : BqlBool.Field<hold> { }
#endregion
#region OwnerID
[Owner(typeof(workgroupID))]
[PXMassUpdatableField]
[PXMassMergableField]
public int? OwnerID { get; set; }
public abstract class ownerID : BqlInt.Field<ownerID> { }
#endregion
#region WorkgroupID
[PXInt]
[PXSelector(typeof(Search<EPCompanyTree.workGroupID>), SubstituteKey = typeof(EPCompanyTree.description))]
[PXUIField(DisplayName = "Approval Workgroup ID")]
public int? WorkgroupID { get; set; }
public abstract class workgroupID : BqlInt.Field<workgroupID> { }
#endregion
}
}
You also need to have DAC which implements the IAssignedMap
interface. Here’s an example of the custom DAC:
using PX.Data;
using PX.Data.BQL;
using PX.Objects.EP;
using PX.SM;
namespace Sprinterra.ApprovalHowTo
{
[PXCacheName("DC Setup")]
public class DCSetup : IBqlTable, IAssignedMap
{
#region IsActive
[PXDBBool()]
[PXDefault(false)]
public virtual bool? IsActive { get; set; }
public abstract class isActive : BqlBool.Field<isActive> { }
#endregion IsActive
#region AssignmentMapID
[PXDBInt]
[PXSelector(typeof(Search<EPAssignmentMap.assignmentMapID,
Where<EPAssignmentMap.entityType, Equal<assignmentMapID.approvableRecord>>>),
typeof(EPAssignmentMap.name),
SubstituteKey = typeof(EPAssignmentMap.name))]
[PXUIField(DisplayName = "Approval Map")]
public virtual int? AssignmentMapID { get; set; }
public abstract class assignmentMapID : BqlInt.Field<assignmentMapID>
{
public class approvableRecord : BqlString.Constant<approvableRecord>
{
public approvableRecord() : base(typeof(EPEquipment).FullName) { }
}
}
#endregion AssignmentMapID
#region AssignmentNotificationID
[PXDBInt]
[PXSelector(typeof(Search<Notification.notificationID>),
typeof(Notification.name),
SubstituteKey = typeof(Notification.name))]
[PXUIField(DisplayName = "Notification Template")]
public virtual int? AssignmentNotificationID { get; set; }
public abstract class assignmentNotificationID : BqlInt.Field<assignmentNotificationID> { };
#endregion AssignmentNotificationID
}
}
After that, you’ll be able to declare the view:
public EPApprovalAutomation<DCApprovableEPEquipment, DCApprovableEPEquipment.approved, DCApprovableEPEquipment.rejected, DCApprovableEPEquipment.hold, DCSetup> EPApprovalAutomation;
With all this additional logic, it should compile without errors. You might still need to add other functionality to make it work as you expect though.
I hope this helps!