PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

admin 发表于 2018-8-1 13:56:44 |阅读模式

admin 楼主

2018-8-1 13:56:44

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

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

x
Technique  
1 T/ W# a. s/ `  J& ZUse the Item Class Extended Method set to set a new private Permission for an Item. , k* C- ~8 e6 D; t7 @8 R) Y
JavaScript  
. c' M' w0 d/ ]$ A% V( R  K// Set up the Part query
+ D/ b' E, X7 h* T9 Hvar innovator = this.newInnovator();
5 m! ~, J8 m2 M3 z) Svar qryItem = this.newItem("Part", "get"); , p+ l5 ?, j& e) g5 P, x9 ]" O
qryItem.setAttribute("select", "id,permission_id"); & h/ l- Q0 e# Z  G& m
qryItem.setProperty("item_number", "123-456%", "like");
: y+ [  v) m/ J; @ - p. l1 T! r/ C+ `9 l( `6 G# Z
// Run the query and check for errors
; Z& Y- G) j8 Tvar resultItem = qryItem.apply();
- e; B' {( L7 D2 @if (resultItem.isError()) {
! V; Z8 o9 ]  d9 y7 a: A top.aras.AlertError(resultItem.getErrorDetail()); * r! h( Z1 `- M, B5 B
return; 1 s' \& k) P7 z& o2 ]$ A
}
6 Z% y% d" e, n! O! l, }
; `9 v. `# j. h* g- `! z, e! |// Iterate over the Items returned and add the private permissions for each.
/ v" Z* D# ^: i5 |6 X6 bvar count = resultItem.getItemCount();
" z  {3 a" O0 i0 e2 [for (i=0; i<count; ++i) {
  f) \0 b1 N4 i% n# ? var item = resultItem.getItemByIndex(i); + U+ Z4 l" X7 A- u. [/ Z
// Start with a blank permission
: L- R6 A% t( K1 t2 Y7 Z: s var permItem = item.setPrivatePermission(""); ; J  t8 ^% E0 O# u$ F$ A- s6 C0 o/ z
// To copy from the current permission: permItem = item.setPrivatePermission();
* N1 f3 y1 f$ R8 l' \ // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); , n/ C4 y/ X1 m! H

* M9 w0 y. M: O2 S: h% ^" f permItem.setProperty("name", permItem.getID());
% A  m8 R( U8 k8 k& c9 @ permItem.setIdentityAccess("Component Engineering", "get", true);
! z# G& T: t5 V9 p3 Q permItem.setIdentityAccess("CM", "get", true);
9 X7 d5 I0 s: J3 x' v permItem.setIdentityAccess("CM", "update", true); 5 i) {0 N* V; O# h0 F: H+ A
6 f% J* P' C0 r
// Grant access to the current user's alias identity
2 ^. `& i  X% [% b  r var aliasId = innovator.getUserAliases().split(',')[0]; 4 `2 o, D/ \" R+ @/ [4 `* u, @
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); 4 l+ B$ r& ]. t& K7 b4 I( e
permItem.setIdentityAccess(aliasName, "get", true); # X3 ~, N+ x! R/ C' x* U
5 `5 q5 @. s! v( g1 O8 Q
item.setAction("edit");   ?7 V; j1 O) U" p. D
resultItem = item.apply(); * O& v' a* e6 [9 @  T
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
2 X9 Z2 P; M% r* u7 r+ D1 ~} " c& ~# F3 K/ A) O
7 }: e# z, h+ a) 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二次开发专题模块培训报名开始啦

    我知道了