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

时间:2017-08-03 22:29:11

标签: default doctype acumatica role

有没有办法按用户角色限制文档类型?

例如,我是否可以创建自定义以允许某些用户仅从应付帐款模块的“帐单和调整”屏幕中的下拉菜单中选择“帐单”类型?

1 个答案:

答案 0 :(得分:1)

是的,可以根据登录用户角色填充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 });
      }
    }
  }
}

登录用户在&#39;管理员&#39;角色,只有&#39;比尔&#39;以DocType显示: enter image description here

相关问题