如何通过自动化步骤在Acumatica中使用分配和批准图? [英] How to work with Assignment and Approval Maps in Acumatica via Automation Steps?

查看:68
本文介绍了如何通过自动化步骤在Acumatica中使用分配和批准图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要制作使用情况分配和批准图。在EP205000页上构建的地图使用模板是什么?我在Acumatica的文件coderepository.xml中进行了研究,发现其中有EPApprovalAutomation类。我想使用它,但它要求在参数之间使用实现IAssignedMap接口的类。这带来了另一个问题,因为IAssignedMap接口是内部的,这又带来了另一个难题,如何使用IAssignedMap接口?有什么替代方法?

I need to make usage Assignment and Approval Maps. What is template for usage of maps which are constructed at page EP205000? I made research in file coderepository.xml of Acumatica, and found there EPApprovalAutomation class. I wanted to use it, but it requires among arguments usage of class which implements IAssignedMap interface. It gives another problem, because IAssignedMap interface is internal, which gives another riddle, how to use IAssignedMap interface? What are alternatives?

推荐答案

这个答案可能会晚一点,但是我相信它对其他人可能有用,所以我会分享。

This answer might be coming a bit late, but I'm sure it can be useful to others so I will share it.

数据库的新表和字段

XXSetupApproval

为模块中的批准设置添加新的设置表(进一步XXSetupApproval)。您可以在下面看到所有必填字段,但是如果您想为不同类型的实体拆分批准,则可能需要添加任何其他参数。

Add new setup table for approval settings in your module (XXSetupApproval further). You can see all required fields below, but you may need to add any additional parameters if you want to split approval for different types of entities.

CREATE TABLE XXSetupApproval
(
    CompanyID int NOT NULL,
    ApprovalID int NOT NULL identity,
    AssignmentMapID int NOT NULL,
    AssignmentNotificationID int NULL,
    CreatedByID uniqueidentifier NOT NULL,
    CreatedByScreenID char(8) NOT NULL,
    CreatedDateTime datetime NOT NULL,
    LastModifiedByID uniqueidentifier NOT NULL,
    LastModifiedByScreenID char(8) NOT NULL,
    LastModifiedDateTime datetime NOT NULL,
    Tstamp timestamp NULL,
    IsActive bit NOT NULL
)
GO

ALTER TABLE XXSetupApproval
    ADD CONSTRAINT XXSetupApproval_PK PRIMARY KEY CLUSTERED (CompanyID, ApprovalID) 
GO

XXRegister

修改需要实现的实体表批准机制(进一步XXRegister)。您的实体应该包括三个必填字段,您可以在下面看到。

Modify table of entity for which you need to implement approval mechanism (XXRegister further). Your entity should include three required fields that you can see below.

OwnerID uniqueidentifier NULL,
WorkGroupID int NULL,
Approved bit NOT NULL

XXSetup

修改模块中主要设置的表(进一步设置XXSetup)。您的设置应包括一个必填字段,您可以在下面看到。请根据您的实体名称来命名此标志,因为它将指示是否启用了批准机制(进一步是XXRequestApproval)。

Modify table of main setup in your module (XXSetup further). Your setup should include one required field that you can see below. Name this flag according with your entity name, because it will be indicate whether approval mechanism enabled or not (XXRequestApproval further).

XXRequestApproval bit NULL

数据库的新更新脚本<​​/ strong>

New update scripts for the database

更新XXRegister表,并根据您的条件将所有现有记录的批准标志设置为1。使用您自己的表达式而不是三个点。

Update XXRegister table and set Approved flag equal to 1 for all existing records according with your conditions. Use your own expressions instead of three dots.

EXEC sp_executesql N'UPDATE XXRegister SET Approved = 1 WHERE ...'

代码的新表和字段

AssignmentMapTypeXX

将您的实体添加到AssignmentMapType类中(进一步为AssignmentMapTypeXX)。此类型应仅用于选择所需类型的分配映射。

Add your entity to the AssignmentMapType class (AssignmentMapTypeXX further). This type should be used for select the assignment maps of needed types only.

public static class AssignmentMapType
{
    ...
    public class AssignmentMapTypeXX : Constant<string>
    {
        public AssignmentMapTypeXX() : base(typeof(XXRegister).FullName) { }
    }
    ...
}

XXSetup

将新属性和类添加到根据数据库中的新字段输入XXSetup DAC。

Add new properties and classes to the XXSetup DAC according with new fields in the database. Use any other attributes if needed.

#region XXRequestApproval
public abstract class xXRequestApproval : PX.Data.IBqlField { }
[EPRequireApproval]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Null)]
[PXUIField(DisplayName = "Require Approval")]
public virtual bool? XXRequestApproval { get; set; }       
#endregion

XXSetupApproval

根据数据库中的XXSetupApproval表将新的DAC添加到代码中。 XXSetupApproval DAC应该实现IAssignedMap接口(AssignmentMapID,AssignmentNotificationID,IsActive字段)。

Add new DAC to the code according with XXSetupApproval table in the database. XXSetupApproval DAC should realize IAssignedMap interface (AssignmentMapID, AssignmentNotificationID, IsActive fields). Use any other attributes if needed.

[Serializable]
public partial class XXSetupApproval : IBqlTable, IAssignedMap
{
    #region ApprovalID
    public abstract class approvalID : IBqlField { }
    [PXDBIdentity(IsKey = true)]
    public virtual int? ApprovalID { get; set; }
    #endregion

    #region AssignmentMapID
    public abstract class assignmentMapID : IBqlField { }
    [PXDefault]
    [PXDBInt]
    [PXSelector(typeof(Search<EPAssignmentMap.assignmentMapID, Where<EPAssignmentMap.entityType, Equal<AssignmentMapType.AssignmentMapTypeXX>>>), 
        DescriptionField = typeof(EPAssignmentMap.name))]
    [PXUIField(DisplayName = "Approval Map")]
    public virtual int? AssignmentMapID { get; set; }
    #endregion

    #region AssignmentNotificationID
    public abstract class assignmentNotificationID : IBqlField { }
    [PXDBInt]
    [PXSelector(typeof(PX.SM.Notification.notificationID), SubstituteKey = typeof(PX.SM.Notification.name))]
    [PXUIField(DisplayName = "Pending Approval Notification")]
    public virtual int? AssignmentNotificationID { get; set; }
    #endregion

    #region tstamp
    public abstract class Tstamp : IBqlField { }
    [PXDBTimestamp()]
    public virtual byte[] tstamp { get; set; }     
    #endregion

    #region CreatedByID
    public abstract class createdByID : IBqlField { }
    [PXDBCreatedByID()]
    public virtual Guid? CreatedByID { get; set; }     
    #endregion

    #region CreatedByScreenID
    public abstract class createdByScreenID : IBqlField { }
    [PXDBCreatedByScreenID()]
    public virtual string CreatedByScreenID { get; set; }          
    #endregion

    #region CreatedDateTime
    public abstract class createdDateTime : IBqlField { }
    [PXDBCreatedDateTime()]
    public virtual DateTime? CreatedDateTime { get; set; }         
    #endregion

    #region LastModifiedByID
    public abstract class lastModifiedByID : IBqlField { }
    [PXDBLastModifiedByID()]
    public virtual Guid? LastModifiedByID { get; set; }        
    #endregion

    #region LastModifiedByScreenID
    public abstract class lastModifiedByScreenID : IBqlField { }
    [PXDBLastModifiedByScreenID()]
    public virtual string LastModifiedByScreenID { get; set; }         
    #endregion

    #region LastModifiedDateTime
    public abstract class lastModifiedDateTime : IBqlField { }
    [PXDBLastModifiedDateTime()]
    public virtual DateTime? LastModifiedDateTime { get; set; }        
    #endregion

    #region IsActive
    public abstract class isActive : IBqlField { }
    [PXDBBool()]
    [PXDefault(typeof(Search<XXSetup.xXRequestApproval>), PersistingCheck = PXPersistingCheck.Nothing)]
    public virtual bool? IsActive { get; set; }
    #endregion
}

XXRegister

将PXEmailSource属性添加到XXRegister DAC,这是分配和批准图树选择器所必需的。

Add PXEmailSource attribute to the XXRegister DAC, it is required for "Assignment and Approvals Maps" tree selector.

[PXEMailSource]
public partial class XXRegister : IBqlTable, EP.IAssign ...

根据数据库中的新字段向XXRegister DAC添加新属性和类。 XXRegister DAC应该实现IAssign接口(OwnerID,WorkgroupID字段)。如果需要,请使用其他任何属性。使用您自己的表达式而不是三个点。

Add new properties and classes to the XXRegister DAC according with new fields in the database. XXRegister DAC should realize IAssign interface (OwnerID, WorkgroupID fields). Use any other attributes if needed. Use your own expressions instead of three dots.

#region OwnerID
public abstract class ownerID : IBqlField { }
[PXDBGuid()]
[PXDefault(typeof(...), PersistingCheck = PXPersistingCheck.Nothing)]
[PX.TM.PXOwnerSelector()]
[PXUIField(DisplayName = "Owner")]
public virtual Guid? OwnerID { get; set; }
#endregion

#region WorkgroupID
public abstract class workgroupID : IBqlField { }
[PXDBInt]
[PXDefault(typeof(...), PersistingCheck = PXPersistingCheck.Nothing)]
[PX.TM.PXCompanyTreeSelector]
[PXUIField(DisplayName = "Workgroup", Enabled = false)]
public virtual int? WorkgroupID { get; set; }      
#endregion

#region Approved
public abstract class approved : IBqlField { }
[PXDBBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Approved", Visibility = PXUIVisibility.Visible, Enabled = false)]
public virtual bool? Approved { get; set; }    
#endregion

#region Rejected
public abstract class rejected : IBqlField { }
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
public bool? Rejected { get; set; }    
#endregion

状态

为实体添加新的批准状态,并在列表中使用它们。

Add new approval statuses for the entity and use them in the list. Use other letters if "P" and "R" already in use.

public const string PendingApproval = "P";
public const string Rejected = "R";

public class ListAttribute : PXStringListAttribute
{
    public ListAttribute() : base(
    new string[] { ..., PendingApproval, Rejected, ... },
    new string[] { ..., EP.Messages.PendingApproval, EP.Messages.Rejected, ... }) { ; }
}

实体图的新代码

在与您的实体一起操作的图中实施EPApprovalAutomation帮助程序。使用您自己的参数而不是三个点。

Implement EPApprovalAutomation helper in the graph which is manipulating with your entity. Use your own parameters instead of three dots.

public EPApprovalAutomation<...> Approval;

为XXSetupApproval DAC添加视图。使用您自己的表达式而不是三个点。

Add view for the XXSetupApproval DAC. Use your own expressions instead of three dots.

public PXSelect<XXSetupApproval, Where<...>> SetupApproval;

主要设置图表的新代码

添加XXSetupApproval DAC的视图。

Add view for the XXSetupApproval DAC.

public PXSelect<APSetupApproval> SetupApproval;

根据XXRequestApproval字段的新值更新每个XXSetupApproval行。

Update each XXSetupApproval row according with new value of the XXRequestApproval field.

protected virtual void XXSetup_XXRequestApproval_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
{
    PXCache cache = this.Caches[typeof(XXSetupApproval)];
    foreach (XXSetupApproval setup in PXSelect<XXSetupApproval>.Select(this))
    {
        setup.IsActive = (bool?)e.NewValue;
        cache.Update(setup);
    }
}

网页的新表格和字段

XXSetup.aspx

添加带有批准设置的新标签页到安装程序的主页(进一步是XXSetup.aspx)。

Add new tab with approval settings to the main web page of the setup (XXSetup.aspx further). Use any other parameters if needed.

<px:PXTabItem Text="Approval">             
    <Template>
        <px:PXPanel ID="panelApproval" runat="server" >
            <px:PXLayoutRule runat="server" LabelsWidth="S" ControlSize="XM" />
            <px:PXCheckBox ID="chkXXRequestApproval" runat="server" AlignLeft="True" Checked="True" DataField="XXRequestApproval" CommitChanges="True" />                    
        </px:PXPanel>
        <px:PXGrid ID="gridApproval" runat="server" DataSourceID="ds" SkinID="Details" Width="100%" >
            <AutoSize Enabled="True" />
            <Levels>
                <px:PXGridLevel DataMember="SetupApproval" >
                    <RowTemplate>
                        <px:PXLayoutRule runat="server" StartColumn="True" LabelsWidth="M" ControlSize="XM" />
                        <px:PXSelector ID="edAssignmentMapID" runat="server" DataField="AssignmentMapID" AllowEdit="True" CommitChanges="True" />
                        <px:PXSelector ID="edAssignmentNotificationID" runat="server" DataField="AssignmentNotificationID" AllowEdit="True" />
                    </RowTemplate>
                    <Columns>
                        <px:PXGridColumn DataField="AssignmentMapID" Width="250px" RenderEditorText="True" TextField="AssignmentMapID_EPAssignmentMap_Name" />
                        <px:PXGridColumn DataField="AssignmentNotificationID" Width="250px" RenderEditorText="True" />
                    </Columns>
                </px:PXGridLevel>
            </Levels>                       
        </px:PXGrid>
        </Template>
</px:PXTabItem>

XXRegister.aspx

将新字段已批准添加到实体的主页(进一步为XXRegister.aspx)。

Add new field "Approved" to the main web page of the entity (XXRegister.aspx further). Use any other parameters if needed.

<px:PXCheckBox ID="chkApproved" runat="server" DataField="Approved" CommitChanges="True" Enabled="False" />

在XXRegister.aspx网页上添加带有批准信息的新选项卡。

Add new tab with approval information to the XXRegister.aspx web page. Use any other parameters if needed.

<px:PXTabItem Text="Approval Details" BindingContext="form" RepaintOnDemand="false">
    <Template>
        <px:PXGrid ID="gridApproval" runat="server" DataSourceID="ds" Width="100%" SkinID="DetailsInTab" NoteIndicator="True" Style="left: 0px; top: 0px;">
            <AutoSize Enabled="True" />
            <Mode AllowAddNew="False" AllowDelete="False" AllowUpdate="False" />
            <Levels>
                <px:PXGridLevel DataMember="Approval">
                    <Columns>
                        <px:PXGridColumn DataField="ApproverEmployee__AcctCD" Width="160px" />
                        <px:PXGridColumn DataField="ApproverEmployee__AcctName" Width="160px" />
                        <px:PXGridColumn DataField="ApprovedByEmployee__AcctCD" Width="100px" />
                        <px:PXGridColumn DataField="ApprovedByEmployee__AcctName" Width="160px" />
                        <px:PXGridColumn DataField="ApproveDate" Width="90px" />
                        <px:PXGridColumn DataField="Status" AllowNull="False" AllowUpdate="False" RenderEditorText="True"/>
                        <px:PXGridColumn DataField="WorkgroupID" Width="150px" />
                    </Columns>
                </px:PXGridLevel>
            </Levels>
        </px:PXGrid>
    </Template>
</px:PXTabItem>

自动化定义的新自动化步骤

这是批准实施过程中最困难的部分,因为应在实体的当前行为范围内创建一些新的自动化步骤。例如,实体具有相应的下一个状态和自动化步骤:保留->打开。我们应该在这两个步骤之间实施批准机制。然后应创建三个新的自动化步骤:保留(如果我们不需要批准文档),保留待批准(如果我们需要批准文档),待批准(从以下步骤开始)实体应被批准还是拒绝)。新的生命周期将如下所示:保留->保留打开或保留待批准->打开或待批准。因此,保持开放和待审批自动化步骤只是确定保持之后应使用哪个自动化步骤的开关。

This is the most difficult part during approval implementation because a few new automation steps should be created in the scope of current behavior of the entity. For example, the entity has next statuses and automation steps accordingly: "Hold" -> "Open". And we should implement approval mechanism between those two steps. Then three new automation steps should be created: "Hold-Open" (if we don’t need to approve the document), "Hold-Pending Approval" (if we need to approve the document), "Pending Approval" (step from which the entity should be approved or rejected). New life cycle will be looks like this: "Hold" -> "Hold-Open" OR "Hold-Pending Approval" -> "Open" OR "Pending Approval". So "Hold-Open" and "Hold-Pending Approval" automation steps are only switches, that determine, which automation step should be used after "Hold".

<Step StepID="Hold-Open" Description="Hold-Open" GraphName="…" ViewName="Document" TimeStampName="tstamp">
    <Filter FieldName="Status" Condition="Equals" Value="H" Operator="And" />
    <Filter FieldName="Hold" Condition="Equals" Value="False" Value2="False" Operator="And" />
    <Filter FieldName="Approved" Condition="Equals" Value="True" Value2="False" Operator="And" />
    <Action ActionName="*" IsDefault="1">
        <Fill FieldName="Status" Value="N" />
    </Action>
 </Step>
<Step StepID="Hold-Pending Approval" Description="Hold-Pending Approval" GraphName="…" ViewName="Document" TimeStampName="tstamp">
    <Filter OpenBrackets="1" FieldName="Status" Condition="Equals" Value="H" Operator="Or" />
    <Filter FieldName="Status" Condition="Equals" Value="N" CloseBrackets="1" Operator="And" />
    <Filter FieldName="Hold" Condition="Equals" Value="False" Value2="False" Operator="And" />
    <Filter FieldName="Approved" Condition="Equals" Value="False" Value2="False" Operator="And" />
    <Action ActionName="*" IsDefault="1">
        <Fill FieldName="Status" Value="P" />
    </Action>
</Step>

















感谢Acumatica开发团队的Evgeny Kralko的工作。

Thanks to Evgeny Kralko from the Acumatica dev team for his work.

这篇关于如何通过自动化步骤在Acumatica中使用分配和批准图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆