Skip to main content
Solved

Reg : Approval Process screen for Equipment Screen (EP208000)

  • 4 July 2024
  • 7 replies
  • 84 views

Hi Team,

 

I want to create approval process screen for Equipment and facing difficulties that EPEquipment Standard PrimaryDAC not implemented with IAssign interface. I am getting following error

 

error CS0311: The type 'PX.Objects.EP.EPEquipment' cannot be used as type parameter 'SourceAssign' in the generic type or method 'EPApprovalAutomation<SourceAssign, Approved, Rejected, Hold, SetupApproval>'. There is no implicit reference conversion from 'PX.Objects.EP.EPEquipment' to 'PX.Data.EP.IAssign'.

 

Regards,

Sakthi

7 replies

Userlevel 6
Badge +4

Hi @sakthi61 ,

The error you're facing indicates that the EPEquipment class does not implement the IAssign interface, which is required by the EPApprovalAutomation generic type. To create an approval process for EPEquipment, you need to make sure that the EPEquipment class implements the IAssign interface. If the standard DAC does not implement this interface, you can create a DAC extension to implement it.

ex. public class EPEquipment_Extension : PXCacheExtension<EPEquipment>, IAssign 

Badge

Hi Dipak Nilkanth,

 

If i add the IAssign to my Extenstion class i am getting the following error in

 

EApprovalAutomation Property

 

  [PXViewName("Approval")]
        public EPApprovalAutomation<EPEquipmentDCExt, EPEquipmentDCExt.approved, EPEquipmentDCExt.rejected, EPEquipmentDCExt.hold, YTLEquipmentApprovalSetup> Approval;

 

Severity    Code    Description    Project    File    Line    Suppression State
Error    CS0311    The type 'PX.Objects.EP.EPEquipmentDCExt' cannot be used as type parameter 'SourceAssign' in the generic type or method 'EPApprovalAutomation<SourceAssign, Approved, Rejected, Hold, SetupApproval>'. There is no implicit reference conversion from 'PX.Objects.EP.EPEquipmentDCExt' to 'PX.Data.IBqlTable'.    PurchasingPackage    C:\Program Files\Acumatica ERP\AcumaticaUpgradeDB\App_Data\Projects\PurchasingPackage\PurchasingPackage\DieselCustomization\Extension\Graph\EquipmentMaint.cs    72    Active
 

 

 

Regards,

Sakthi

Badge

Hi Dipak,

 

Any solution for the above issue.

 

Regards,

Sakthi

Userlevel 7
Badge +9

@andriitkachenko @NicholasBova52 @Hughes Beausejour @Dmitrii Naumov 

Your input is greatly appreciated

Userlevel 4
Badge +1

Severity    Code    Description    Project    File    Line    Suppression State
Error    CS0311    The type 'PX.Objects.EP.EPEquipmentDCExt' cannot be used as type parameter 'SourceAssign' in the generic type or method 'EPApprovalAutomation<SourceAssign, Approved, Rejected, Hold, SetupApproval>'. There is no implicit reference conversion from 'PX.Objects.EP.EPEquipmentDCExt' to 'PX.Data.IBqlTable'.    PurchasingPackage    C:\Program Files\Acumatica ERP\AcumaticaUpgradeDB\App_Data\Projects\PurchasingPackage\PurchasingPackage\DieselCustomization\Extension\Graph\EquipmentMaint.cs    72    Active

This error is because EPEquipmentDCExt is a CacheExtension and not a class that directly inherits IBqlTable, so EPApprovalAutomation won’t accept that class as the parameter for the SourceAssign generic type. Since the SourceAssign generic argument has to inherit from both IAssign and IBqlTable, it doesn’t seem like it’s possible to get this to work with a CacheExtension.

 

You might be able to get this to work with a normal DAC that inherits IAssign and IBqlTable and pulls the EPEquipment data in a PXProjection instead? But I can’t guarantee that this would work properly with the base assignment/approval maps functionality.

Userlevel 6
Badge +2

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 IBqlTableEPEquipment 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
{
/// <summary>
/// Child class of the <see cref="EPEquipment"/>, created to allow approval workflow for the equipment records.
/// </summary>
[PXCacheName("Approvable Equipment")]
public sealed class DCApprovableEPEquipment : EPEquipment, IAssign
{
// Approval
#region Approved
/// <summary>
/// Specifies (if set to <c>true</c>) that it has been approved by a responsible person and is in the Approved now.
/// </summary>
[PXDBBool]
[PXUIField(DisplayName = "Approve", Visibility = PXUIVisibility.Visible)]
[PXDefault(false)]
public bool? Approved { get; set; }
public abstract class approved : BqlBool.Field<approved> { }
#endregion

#region Rejected
/// <summary>
/// Specifies (if set to <c>true</c>) that it has been rejected by a responsible person.
/// </summary>
[PXDBBool]
public bool? Rejected { get; set; }
public abstract class rejected : BqlBool.Field<rejected> { }
#endregion

#region Hold
/// <summary>
/// Specifies (if set to true) that it is On Hold
/// </summary>
[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
/// <summary>
/// The ID of the workgroup which was assigned to approve the transaction.
/// </summary>
[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
{
// Approval configuration
#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!

Userlevel 6
Badge +2

I’ve also just shared step-by-step guide to set up Approvals here.

Reply