A client is looking to have the Branch visible on the Approvals screen.
That particular field is not available in the screen editor in the Add Data Fields of the Customization Project.
Any advise on how to get that field published?
Thank you,
Mike
Page 1 / 1
The screen uses a projection (EPOwned) that inherits from EPApproval and adds fields. The screens with approvals use CacheAttached objects to set the values that are to be presented through EPApproval to fields of the record being approved through that record’s graph. To do this, you need to:
Add UsrBranchID to EPApproval in the database (via the customization project)
Create/Edit a DAC extension to extend EPApproval to include UsrBranchID as a field
Use CacheAttached to populate it
Update the Approval screen to show the Branch field
DAC Extension for EPApproval to add the Branch ID field
using PX.Data; using PX.Objects.GL;
namespace PX.Objects.EP { public sealed class EPApprovalExt : PXCacheExtension<PX.Objects.EP.EPApproval> { #region UsrBranchID PXDBInt] PXSelector( typeof(Search<Branch.branchID, Where<Branch.branchID, Equal<Current<usrBranchID>>>>), typeof(Branch.branchCD), SubstituteKey = typeof(Branch.branchCD) )] PXUIField(DisplayName = "Branch")] public int? UsrBranchID { get; set; } public abstract class usrBranchID : PX.Data.BQL.BqlInt.Field<usrBranchID> { } #endregion } }
Populating via CacheAttached
Add CacheAttached in a Graph Extension for the object being approved (MyDAC in this case)…
Now that these are added, after compiling and updating your project with the new DLL, customize the EP503010 screen to add your new UsrBranchID field to the screen.
It is important to note that the Branch ID will appear only on new approvals created after you add the CacheAttached because that CacheAttached is defaulting in the branch ID on the approval record from the DAC being approved. Therefore, it only exists when the approval record is created, and only after adding the CacheAttached to every approval-enabled screen where you want it to appear in the Approvals. As you can see in the example below, only the top record has the branch ID as it is the only one that was created with the CacheAttached as shown above being in place.
Hi Brian,
Thank you for the detailed explanation.
After creation of the DAC Extension I ran Validation that failed and the following errors appeared:
Building directory '\WebSiteValidationDomain\App_RuntimeCode\'.
\App_RuntimeCode\EPApproval.cs(28): error CS0101: The namespace 'PX.Objects.EP' already contains a definition for 'EPApprovalExt'
\App_RuntimeCode\PX_Objects_EP_EPApproval_extensions.cs(14): error CS0101: The namespace 'PX.Objects.EP' already contains a definition for 'EPApprovalExt'
\App_RuntimeCode\EPApproval.cs(20): error CS0549: 'EPApprovalExt.UsrCustomField.get' is a new virtual member in sealed class 'EPApprovalExt'
\App_RuntimeCode\EPApproval.cs(20): error CS0549: 'EPApprovalExt.UsrCustomField.set' is a new virtual member in sealed class 'EPApprovalExt'
\App_RuntimeCode\PX_Objects_EP_EPApproval_extensions.cs(20): error CS0549: 'EPApprovalExt.UsrBranchID.get' is a new virtual member in sealed class 'EPApprovalExt'
\App_RuntimeCode\PX_Objects_EP_EPApproval_extensions.cs(20): error CS0549: 'EPApprovalExt.UsrBranchID.set' is a new virtual member in sealed class 'EPApprovalExt'
\App_RuntimeCode\EPApproval.cs(40): error CS0263: Partial declarations of 'EPApprovalExt.usrBranchID' must not specify different base classes
\App_RuntimeCode\EPApproval.cs(34): error CS0311: The type 'PX.Objects.EP.EPApprovalExt.usrBranchID' cannot be used as type parameter 'Field' in the generic type or method 'Current<Field>'. There is no implicit reference conversion from 'PX.Objects.EP.EPApprovalExt.usrBranchID' to 'PX.Data.IBqlField'.
\App_RuntimeCode\EPApproval.cs(28): error CS0101: The namespace 'PX.Objects.EP' already contains a definition for 'EPApprovalExt'
Compiler time, in seconds: 9.3590506
There’s Imperium module as level 1 customization published in the instance, but it doesn’t have customizations to EP503010 screen.
Any suggestions?
Thank you,
Mike
I’m not familiar with whatever customizations you may have already. As you can see from the screenshot I included, the code works in my environment. Customizing EP503010 is irrelevant as the error itself complains specifically of the DAC extension. Since I don’t have access to your code, I can’t see if Imperium modifies the EPApproval DAC.
Do you by chance have EPApprovalExt defined in the customization project AND in your visual studio extension library? Based on the error, if you are still stuck, I’d try changing the name of your specific DAC Extension to something like EPApprovalExt2 and see if that gets around your issue or helps you isolate the issue.
This message leads me to think you have started defining the field and didn’t finish.
\App_RuntimeCode\EPApproval.cs(34): error CS0311: The type 'PX.Objects.EP.EPApprovalExt.usrBranchID' cannot be used as type parameter 'Field' in the generic type or method 'Current<Field>'. There is no implicit reference conversion from 'PX.Objects.EP.EPApprovalExt.usrBranchID' to 'PX.Data.IBqlField'.
As you can see in my code, the field inherits PX.Data.BQL.BqlInt.Field<usrBranchID> which makes it an IBqlField.
Also, while I tend to apply graph and DAC extensions to the same namespace that the original resides, I believe it is possible to put them in your own namespace. I’ve seen it done both ways through the years.
Several of our clients have implemented and multi-branch configuration for Acumatica and many of them are using Approval Maps. I know of at least two of our clients who have requested to have the Branch ID and/or Branch Name visible on the Approvals screen (EP503010) so that they can easily see the branch the document is associated with, without having to click into the transaction. I know that we did this customization for at least one client. But I think it would be valuable for any client with multiple branches, who are using approvals. So I’ve created the following product idea. Please vote.