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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x
Technique  
; a( W; i; G1 @5 |+ FUse the Item Class Extended Method set to set a new private Permission for an Item.
6 k; c8 T+ p" |; \JavaScript  8 d' u# I2 U$ U
// Set up the Part query
  p! K- L! ^1 a% o0 C" J* lvar innovator = this.newInnovator();
1 A6 X/ k& X* I' N0 h& Evar qryItem = this.newItem("Part", "get"); 5 k' G3 I! E7 z
qryItem.setAttribute("select", "id,permission_id"); ) s8 ?+ q9 S6 K* X7 I
qryItem.setProperty("item_number", "123-456%", "like");
, f# l4 g; v8 W9 P9 F* b
  q8 _# Q, t8 c6 m  e3 e" k// Run the query and check for errors ' ]& K4 X, \' v. `# S7 W" g' `, E# T
var resultItem = qryItem.apply();
! ]+ H3 g4 I& L4 I" t6 o1 Q0 s) sif (resultItem.isError()) {
/ ~- x) g: R# j6 T; B6 L/ ~! z: n top.aras.AlertError(resultItem.getErrorDetail());
. c7 h- F9 t, o; Q7 I! @, g- M return; % I3 V- @3 [* a  N: S2 g
}
3 I7 ], h6 H0 \5 B+ ~( Y / k2 \' d1 _+ K# T
// Iterate over the Items returned and add the private permissions for each. . ]+ y# ^% O+ a3 `* ?0 w
var count = resultItem.getItemCount(); ! e( F6 ^1 x; U) _# s( T
for (i=0; i<count; ++i) { + v5 l+ I8 P9 X: m4 W! @
var item = resultItem.getItemByIndex(i);
) S4 P2 l( U$ C6 {- q0 f- N // Start with a blank permission
* S! V( E: W: t0 W9 a3 m var permItem = item.setPrivatePermission(""); ! ]2 E/ p! e' n) G, ]! e2 q
// To copy from the current permission: permItem = item.setPrivatePermission(); 7 V/ {. V- V( s" J, t- t) y/ p3 A
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
% P% I  x. h; n " d+ g+ N8 o* E: R$ n
permItem.setProperty("name", permItem.getID()); 0 E$ b# h9 c* @" L% ~0 f, Z' }
permItem.setIdentityAccess("Component Engineering", "get", true);
3 B/ F2 f3 x1 K" J: ? permItem.setIdentityAccess("CM", "get", true);
% b1 X0 Q( o: a5 t( x' l; ~ permItem.setIdentityAccess("CM", "update", true);
. Y. ^% p& S$ i  d. _: o9 _8 s
1 @2 c$ |6 @- V& P // Grant access to the current user's alias identity
( o( O& a& P1 B8 r  J# ~# v var aliasId = innovator.getUserAliases().split(',')[0]; 6 \( A' x3 X0 _* ?; ~
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
: M2 x' C; W) p: J1 y1 i" f# i0 J9 Y permItem.setIdentityAccess(aliasName, "get", true); 1 f9 N& n4 y! B3 C
- h2 C3 J; H$ e: ]
item.setAction("edit"); ' p- _# G  m& v, E
resultItem = item.apply(); 2 {/ W; l" f6 M2 ?
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 7 y4 E# `  h4 ]. k/ k- v
} + l# z* I6 z4 H% W

9 \/ h. B9 I9 ~
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了