查看: 2450|回复: 0

【Aras 二次开发代码】为对象Item设置私有权限

[复制链接]

2480

主题

1280

回帖

8万

积分

管理员

PLM之家站长

积分
82278
QQ
发表于 2018-8-1 13:56:44 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×
Technique  
/ e0 a& s" Y: |Use the Item Class Extended Method set to set a new private Permission for an Item. * j' j' f& L7 m  |% @
JavaScript  
' @/ ^9 q  _9 h' P+ C// Set up the Part query ) G& q1 I% B5 m& P1 g
var innovator = this.newInnovator(); , v" j, D' v3 i0 N
var qryItem = this.newItem("Part", "get"); % a' y" a% m1 R8 n: _
qryItem.setAttribute("select", "id,permission_id");
$ p: L, y  ]* v" lqryItem.setProperty("item_number", "123-456%", "like");
  {* l. m+ j; |. l* `' q * v9 e$ o8 P1 x& V. W2 v
// Run the query and check for errors 0 c8 o; X! E1 q6 b
var resultItem = qryItem.apply(); % U  S6 b$ B0 _. H
if (resultItem.isError()) {
- C( w8 U8 f& I, C8 l( ? top.aras.AlertError(resultItem.getErrorDetail());
& s8 ~! |: ?5 u/ W! e( w+ E: K8 O3 d8 [ return;
; S, z+ s, Q' J* F4 l4 @} 7 o0 I! X& A  K; e

1 \, `& u8 w  b  i// Iterate over the Items returned and add the private permissions for each.
0 q4 l2 y% @- y/ y# Rvar count = resultItem.getItemCount(); . \3 s( v* s" l7 h; e& U$ A
for (i=0; i<count; ++i) { 7 t3 O9 ^( s( Q6 R* k
var item = resultItem.getItemByIndex(i);
/ K0 b, v5 \3 e6 m // Start with a blank permission ' N& n. _: S6 _0 |2 P7 j; }
var permItem = item.setPrivatePermission(""); 3 J( t" V, ~, v% U9 g
// To copy from the current permission: permItem = item.setPrivatePermission();
1 ]$ {" _2 v, m9 g // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); 2 v$ n% U/ `8 i( n. i$ M' y2 a

* j( }8 d& F2 T/ l6 B permItem.setProperty("name", permItem.getID());
- P3 O- Q+ w  A. u permItem.setIdentityAccess("Component Engineering", "get", true);
/ h# X4 r6 y! P' n" Y permItem.setIdentityAccess("CM", "get", true);
8 S+ T% c2 f# s7 g permItem.setIdentityAccess("CM", "update", true); 5 Q! t/ k( Z8 [; r$ W: p! Z
" x0 {3 {: h. m
// Grant access to the current user's alias identity 7 `+ q: H4 M# o- O* e3 ?
var aliasId = innovator.getUserAliases().split(',')[0];
7 u% N0 @$ n, E, F/ N% ^ var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
/ P, H" a* |1 |' k  j permItem.setIdentityAccess(aliasName, "get", true); * ~* |8 R6 g7 m5 m5 J' ]

' o# X4 q7 J$ p7 A2 F item.setAction("edit");
! d' D* R  x. D+ Z  r) G resultItem = item.apply();
) W) J2 Y) @5 q  a9 _# k if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
6 d* X4 o. q' X5 W" G' Q}
# g, _4 l+ `$ b( Y: X0 ?1 t3 q+ R8 R
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部