Acumatica设置默认文档类型按角色

问题描述:

有没有办法通过用户角色限制文档类型?Acumatica设置默认文档类型按角色

例如,我可以创建自定义以允许某些用户只从Accounts Payable模块的Bills and Adjustment屏幕的下拉列表中选择“Bill”类型?

是的,可以根据登录用户角色填充DocType列表。

代码示例为 '管理员' 的角色:

using PX.Data; 
using PX.Objects.AP; 
using PX.SM; 

namespace PX.Objects.AP 
{ 
  public class APInvoiceEntry_Extension:PXGraphExtension<APInvoiceEntry> 
  { 
    public PXSelect<UsersInRoles, 
           Where<UsersInRoles.username, Equal<Current<AccessInfo.userName>>, 
           And<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>>>> isLoginUserInRole; 

    public void APInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e) 
    { 
      if (isLoginUserInRole.Select("Administrator").Count > 0) 
      { 
          PXDefaultAttribute.SetDefault<APInvoice.docType>(sender, APDocType.Invoice); 
         
          PXStringListAttribute.SetList<APInvoice.docType>(sender, 
                                                           null, 
                                                           new string[] { APDocType.Invoice }, 
                                                           new string[] { Messages.Invoice }); 
      } 
    } 
  } 
} 

当登录用户是 '管理员' 的角色,只有 '比尔' 显示DOCTYPE中: enter image description here

+0

真棒!这工作完美 – jckta