PLM之家PLMHome-工业软件践行者

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

[复制链接]

2018-8-1 13:56:44 2173 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x
Technique  # M) f; N: ?8 H0 w0 H
Use the Item Class Extended Method set to set a new private Permission for an Item. 6 s  Y. G  \0 Q' D4 @
JavaScript  3 |6 Y: ?  W) @( Y) W* X) V
// Set up the Part query
5 C  E: ?) j, {8 Avar innovator = this.newInnovator(); 0 ~6 _4 [! q* K: {( s& C8 }0 l
var qryItem = this.newItem("Part", "get");   B; I3 T3 j" j% E
qryItem.setAttribute("select", "id,permission_id");
9 H$ O  x1 e2 q$ a( f) H; EqryItem.setProperty("item_number", "123-456%", "like"); ) Q! [& }# h$ J8 L8 l

8 O( _1 d, Z8 ?( r! `// Run the query and check for errors
/ g. t: H+ L5 A1 N' N- z$ Rvar resultItem = qryItem.apply(); / h5 B# N; E+ X1 b9 B$ g9 w
if (resultItem.isError()) { ; L4 t. u  t" d
top.aras.AlertError(resultItem.getErrorDetail()); . A, s( b+ B. x% M5 @; j
return; / t8 Z; r# @5 H" n
}
6 ]3 Z. |2 N% r8 I" P# q& Z , e$ ?( c  R4 T( B  J: e
// Iterate over the Items returned and add the private permissions for each. 4 R& k+ _" a& ^3 u; O; @
var count = resultItem.getItemCount(); % o5 p+ H6 D, \  V" p8 \! L
for (i=0; i<count; ++i) {
! ~0 j$ V( S! O var item = resultItem.getItemByIndex(i);   ?) @) d- b& }" f" k9 Y8 n
// Start with a blank permission 9 q4 {( o: D* d) D' h2 e1 s5 S, Z
var permItem = item.setPrivatePermission(""); - q: H- H) s7 j9 \" b
// To copy from the current permission: permItem = item.setPrivatePermission(); # f9 b7 E/ [  h. l/ j
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
" z) x; i, m; i* ?; d , o) a( [/ }  o0 e2 H. q# K* `
permItem.setProperty("name", permItem.getID());
% Z( o- f6 z7 K; _ permItem.setIdentityAccess("Component Engineering", "get", true); , B7 I' Z  a, O/ s& d- H
permItem.setIdentityAccess("CM", "get", true);
+ E; ]" o' J/ a+ x6 D4 G permItem.setIdentityAccess("CM", "update", true); ' D" l# ^3 ^" ?4 _- ]
8 {. ~7 T' X$ {9 n
// Grant access to the current user's alias identity 7 t2 d  |- G! o8 ?3 s1 Z. O
var aliasId = innovator.getUserAliases().split(',')[0];
8 e: [, |+ w9 T) k3 v) [) P var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ' Z$ {# F2 C! c! d+ V
permItem.setIdentityAccess(aliasName, "get", true);
, K) P  |" ?* g$ [8 ]- S( j
/ h: o$ F  z' v, |7 f item.setAction("edit");
# i! q+ U5 h0 R- Z resultItem = item.apply();
" q# T! |7 m- H8 B7 c) l0 a if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
) ?/ Y- z; B: l} 0 y) U. ^0 _% k& P: T  R. O

' q! A  B( Q1 `& E
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了