查看: 2254|回复: 0

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

[复制链接]

4

主题

3

回帖

44

积分

管理员

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

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

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

×
Technique  
  Y# |9 ~+ }" ]) s. |' MUse the Item Class Extended Method set to set a new private Permission for an Item. & {* l( w# x6 j" S1 Y/ T
JavaScript  
  S* j  S. \4 W// Set up the Part query 1 U1 V& P3 p. P' w3 I0 z
var innovator = this.newInnovator();
2 P+ s* _& |' k  fvar qryItem = this.newItem("Part", "get");
9 ]/ C& w7 z% i2 _& y, ~0 m; \qryItem.setAttribute("select", "id,permission_id"); 3 C) P5 j' b$ l: |$ ]
qryItem.setProperty("item_number", "123-456%", "like"); 5 y( }1 q  D1 [2 b7 t9 f

( h! v' W# D# M/ D5 h1 A3 d% M// Run the query and check for errors 3 N6 ], a$ I: X1 b9 ~
var resultItem = qryItem.apply(); / U7 L5 V) u. y* S7 L
if (resultItem.isError()) { 0 v. z$ [; x2 [* w5 j/ E+ L/ E8 B
top.aras.AlertError(resultItem.getErrorDetail());
9 o  h3 ?! Z  K return;
8 f8 l8 A  K8 S' J4 \0 r- {& _} * T% }. e# y- D% f5 Q
' L4 p0 E3 _! W# P
// Iterate over the Items returned and add the private permissions for each. # }2 [' d- m6 I
var count = resultItem.getItemCount();   t8 J; m9 b$ F8 g5 g1 H
for (i=0; i<count; ++i) { & c" }+ ^* Y; w# d9 m
var item = resultItem.getItemByIndex(i);
7 {2 n" `5 ^4 E/ V8 [! i // Start with a blank permission . n* a& Z; L9 }5 Z8 |
var permItem = item.setPrivatePermission("");
) z' ?# P6 _' h // To copy from the current permission: permItem = item.setPrivatePermission(); 5 C! Z& Q6 Y) W/ B% e( W6 X( z7 h1 {
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); # h- b5 Q; ]; Z
; i7 ~8 v9 }3 U, v+ R
permItem.setProperty("name", permItem.getID());
# r& }! r1 R! `. ^* M( r permItem.setIdentityAccess("Component Engineering", "get", true); % R" O/ b& d0 h. v- E# b
permItem.setIdentityAccess("CM", "get", true); + l  ^: B! w8 t, h; }
permItem.setIdentityAccess("CM", "update", true);
" c' ~! E& t; O# s" T5 ]6 a. s ) I( T: D4 D. R4 k! t, Q
// Grant access to the current user's alias identity
$ e7 ~: o# e' ~( P5 z/ Y* z: ~ var aliasId = innovator.getUserAliases().split(',')[0]; % ?) L+ ], q5 K! A$ w
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
5 |1 b% |& I( Y6 D: r permItem.setIdentityAccess(aliasName, "get", true);
! D9 b! R5 J$ g. c
) e4 b: X  O1 z; [$ p7 F! t+ H; X item.setAction("edit");
  F6 b9 C* m, b$ A9 | resultItem = item.apply();
4 r. i& ~( M& L4 `& b+ D if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } % A1 [6 x2 W' \
} * n! g; L: _0 \, j8 C% [% R" `

) ?; p* V! ?/ A8 Q
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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