查看: 2239|回复: 0

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

[复制链接]

4

主题

3

回帖

40

积分

管理员

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

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

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

×
Technique  
1 J2 ]0 J2 @* P$ c& V9 ]! y1 RUse the Item Class Extended Method set to set a new private Permission for an Item.
( Y! ~' E  [; |8 D. c: pJavaScript  
, c" L/ C, H- D; s, J// Set up the Part query
1 y  P0 y# V! e/ c0 h0 E+ ovar innovator = this.newInnovator(); " n  b5 X2 a* S# Y1 o6 J
var qryItem = this.newItem("Part", "get");
. l( V# B1 Q( n: W+ A6 rqryItem.setAttribute("select", "id,permission_id");
, R& Y; K) ?! d' E; s+ N' }qryItem.setProperty("item_number", "123-456%", "like");
" f4 T( s0 y$ V. Z& p
# M  c) W& q9 y( }% |// Run the query and check for errors ; ?9 G# p# ]# T+ R: T
var resultItem = qryItem.apply(); " @4 w+ f0 h7 [  H$ P
if (resultItem.isError()) {
( l" M3 C( X) Z  i; ]* L: V top.aras.AlertError(resultItem.getErrorDetail()); , b9 g% I  u: `! ^
return;
* x+ r8 y, {) c# S: K}
: W( D5 `1 b9 A5 O  ?2 g3 ~
- r8 |/ o0 W5 ~// Iterate over the Items returned and add the private permissions for each.
; N0 r  F, ^/ Y. {var count = resultItem.getItemCount(); 1 g, y. M7 X+ N. t% f
for (i=0; i<count; ++i) { $ W( Y( v( H6 E, L+ D
var item = resultItem.getItemByIndex(i);
, _! s  `0 r/ r: N // Start with a blank permission " Q5 R# w* J1 b5 @" t0 m
var permItem = item.setPrivatePermission(""); 8 J1 ^% g2 n* n5 e* l
// To copy from the current permission: permItem = item.setPrivatePermission(); 1 |+ p  X$ _4 l& ^9 d
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); 9 v* G6 h/ o5 j
: D+ j# u/ [8 y
permItem.setProperty("name", permItem.getID());
) [2 c, M% ^$ s  _# M  y, W8 h permItem.setIdentityAccess("Component Engineering", "get", true);
* U" j* J7 c& k# O permItem.setIdentityAccess("CM", "get", true); 4 P4 _; \4 L5 `9 V
permItem.setIdentityAccess("CM", "update", true);
' u  s8 ]6 N1 R; E7 H1 | ' F! T$ p- l4 ]
// Grant access to the current user's alias identity 2 H& i/ E$ Q# z( c
var aliasId = innovator.getUserAliases().split(',')[0]; 3 \4 v& y4 R. b& J8 Y
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
3 e5 o  C& ~( {5 u% _ permItem.setIdentityAccess(aliasName, "get", true); 8 a" U) q/ k, D" s$ q/ J

2 `0 n% O& h2 J( c item.setAction("edit"); 5 T0 e. ]& `# ?
resultItem = item.apply(); ' U" G/ N9 }5 W6 g& U- b
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } + x. h" e( x5 J3 a- W
}
# k1 c* m3 q" `- P) G$ X, X. C/ p$ w& C1 _- h
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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