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

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

[复制链接]

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

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

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

x
Technique  
+ B# ~3 @7 e7 j* w# X+ O8 H, Q# M' @Use the Item Class Extended Method set to set a new private Permission for an Item.
' T; n2 E. l* f/ s2 j: hJavaScript  : f1 Q0 g: p- T2 Q$ Z
// Set up the Part query : ^2 v7 A# a( p  E, f8 }& U
var innovator = this.newInnovator();
8 v3 b0 u1 k3 Jvar qryItem = this.newItem("Part", "get"); 9 o- [' }; I/ [% w+ x$ Z+ ~
qryItem.setAttribute("select", "id,permission_id"); $ h" U- t, l8 C
qryItem.setProperty("item_number", "123-456%", "like");
3 b. b: Z& M% o  e
% ]- Y9 _0 e  C) r, S9 s// Run the query and check for errors & f. y4 e% }# u' i& k4 c
var resultItem = qryItem.apply();
+ z- S6 E% x- K/ {% p4 X. qif (resultItem.isError()) { % o. M2 I0 W  g8 x
top.aras.AlertError(resultItem.getErrorDetail()); 9 q2 k. R# D- q, Q
return; ) f8 @  f: G9 ]4 M
} ' x  E  Z7 |8 f7 W% {8 @% ~
6 {0 p/ T- a7 V1 c7 b2 p
// Iterate over the Items returned and add the private permissions for each.
) V: v) {! F/ v) @) W* t& T+ g1 U( ?var count = resultItem.getItemCount();
7 r1 K# U3 L6 s: e) X5 _for (i=0; i<count; ++i) { ) Y  S+ b& m% ]+ }5 Z$ d' [! o
var item = resultItem.getItemByIndex(i);   R% z& O1 I+ Z& P- m
// Start with a blank permission . z. r2 J8 {$ y. p
var permItem = item.setPrivatePermission("");
  V3 d7 k$ Y9 I8 C% P) V // To copy from the current permission: permItem = item.setPrivatePermission();   t6 V2 u" H+ B  ~7 G
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); 0 f8 w0 @& k9 [" N3 c
2 m* n: V# c2 |( D8 }: m, f0 v) Y
permItem.setProperty("name", permItem.getID()); 4 [( W& R' s4 s1 x
permItem.setIdentityAccess("Component Engineering", "get", true); $ y, ^0 b1 u. T; V1 i/ C
permItem.setIdentityAccess("CM", "get", true); 6 b; ]* v/ }1 J2 K) S) Q" ^0 c
permItem.setIdentityAccess("CM", "update", true); 5 q$ y! ~! C2 T3 l" Z
8 T" l" B" q0 \& s
// Grant access to the current user's alias identity 1 \! B9 R$ w* P
var aliasId = innovator.getUserAliases().split(',')[0];
5 k# d- c6 ?) o7 f' ]9 k var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); & X& M# O1 K  c$ x% F
permItem.setIdentityAccess(aliasName, "get", true); 5 d' I0 q" M3 d" x7 H/ g

. Q9 _" H! K" X% t item.setAction("edit");
9 I5 K# p* |$ ^5 g6 X( W( f resultItem = item.apply();
, h( Y* W1 {; |) e if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } % w8 ?  I8 r/ R$ P3 t; e# ?2 m4 Z& e
}
/ `# J! \; Z* B2 r9 E6 t+ d* j4 t2 K1 e/ c% @" i+ f& a( o$ N% Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了