Skip to content

Instantly share code, notes, and snippets.

@BrianMRO
Last active September 30, 2021 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianMRO/2953013485936b5646ac6d51eb3355f2 to your computer and use it in GitHub Desktop.
Save BrianMRO/2953013485936b5646ac6d51eb3355f2 to your computer and use it in GitHub Desktop.
Approval - Add Custom Screen
using PX.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using SSCS;
namespace PX.Objects.EP
{
public class EPApprovalMapMaint_Extension : PXGraphExtension<EPApprovalMapMaint>
{
public static bool IsActive() => true; // Insert your own logic here for when to enable
#region Override GetEntityTypeScreens - Enable Approval Maps for New Screens
public delegate IEnumerable<String> GetEntityTypeScreensDelegate();
[PXOverride]
public IEnumerable<String> GetEntityTypeScreens(GetEntityTypeScreensDelegate baseMethod)
{
IEnumerable<string> entities = baseMethod();
List<string> list = new List<string>();
foreach (string s in entities)
{
list.Add(s);
}
list.Add("ZZ301000"); // The screen id for your custom screen to enable approvals
list.Add("ZZ302000"); // The screen id for your next custom screen to enable approvals
return list;
}
#endregion
#region EPRule_RowSelected - Override to Enable Approve/Reject Reasons for New Graphs
protected virtual void EPRule_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)
{
baseEvent.Invoke(sender, e);
EPRule row = e.Row as EPRule;
if (row == null)
return;
// Enable ability to prompt for approve/reject reason
bool isOfSupportedType = new List<string>()
{
typeof(EP.TimeCardMaint).FullName,
typeof(EP.EquipmentTimeCardMaint).FullName,
typeof(EP.ExpenseClaimEntry).FullName,
typeof(PM.ProformaEntry).FullName,
typeof(PM.ChangeOrderEntry).FullName,
typeof(CR.QuoteMaint).FullName,
typeof(PM.PMQuoteMaint).FullName,
typeof(BLOG.MY.BLOGMyCustomScreenGraph).FullName, // Add your custom graph here
typeof(BLOG.MY.BLOGMySecondCustomScreenGraph).FullName, // Add your next custom graph here
}.Contains(Base.AssigmentMap.Current?.GraphType, new PX.Data.CompareIgnoreCase());
PXUIFieldAttribute.SetVisible<EPRule.reasonForApprove>(Base.Nodes.Cache, Base.Nodes.Current, isOfSupportedType && row.StepID != null);
PXUIFieldAttribute.SetVisible<EPRule.reasonForReject>(Base.Nodes.Cache, Base.Nodes.Current, isOfSupportedType && row.StepID != null);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment