PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2018-8-1 13:56:44

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

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

x
Technique  2 R& n7 q: M' b+ K& O
Use the Item Class Extended Method set to set a new private Permission for an Item. $ x; F. N3 s0 l- j3 C5 t2 o/ T
JavaScript  3 h4 z; H# ]; Z
// Set up the Part query ; w$ q+ S) M* @1 f9 E
var innovator = this.newInnovator(); 7 m% i% q5 o& U' }/ ?' D
var qryItem = this.newItem("Part", "get"); ( Y- ?5 _1 X, G
qryItem.setAttribute("select", "id,permission_id"); & |3 v+ ~& @+ P1 _8 p; ^
qryItem.setProperty("item_number", "123-456%", "like");
0 P6 ]0 f$ j# Y+ S1 { * J5 ?9 H8 P* d  N! Z4 n& a! F! F$ I
// Run the query and check for errors
. s$ l; t! i  Q; C" C( s! o4 _$ |var resultItem = qryItem.apply(); 1 t( L. i/ w8 ^: N9 J
if (resultItem.isError()) { 9 O8 T1 v7 Y0 z- |5 ^0 W
top.aras.AlertError(resultItem.getErrorDetail());
! b! I9 R$ T' \0 g9 ~9 d8 ~% Q return;
% H0 {- B& ?" m0 Y- L% E# c} : z- i8 n% P# o, y5 S& B# i6 U

! Q2 \9 _% B: v, w// Iterate over the Items returned and add the private permissions for each.
$ l& g% p7 c4 `" S' B8 R- Bvar count = resultItem.getItemCount();   ]' m- M- \: E% Q) _9 q
for (i=0; i<count; ++i) { , Z: x% ]% U1 b' l) e" s
var item = resultItem.getItemByIndex(i); 1 Z) [% E' p' Q8 A* L9 D# n
// Start with a blank permission
6 J7 ], _" i* m. [% Y& o2 ` var permItem = item.setPrivatePermission("");
3 B' Y) @& S1 m& Y // To copy from the current permission: permItem = item.setPrivatePermission(); * P! A0 o3 d9 d" i
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
9 K6 X+ l! k1 q! h, \3 g
5 Q  R% ~, f6 y" H* Z: K permItem.setProperty("name", permItem.getID());
+ R9 h8 O0 R, ^: A6 d: `) H7 l permItem.setIdentityAccess("Component Engineering", "get", true); % D: O5 g/ }( C* }* I
permItem.setIdentityAccess("CM", "get", true); 2 Y+ B7 y; s+ R! g
permItem.setIdentityAccess("CM", "update", true);   |9 K1 G4 i1 o2 [( x

6 z' O! r/ r5 h5 l) d" }4 D7 | // Grant access to the current user's alias identity 2 R) N1 `2 }' O# E% u
var aliasId = innovator.getUserAliases().split(',')[0]; - g! j) m2 \* G; `
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); 5 b* R$ c/ X# u" |6 X- p
permItem.setIdentityAccess(aliasName, "get", true); ! \# g7 b, K% J6 e7 T( T: y

+ X; X/ k8 w+ _; b, q; S/ R: y  U8 | item.setAction("edit");
' f- W3 l' w5 @( s resultItem = item.apply();
' k8 {; i) l+ U" K if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
% x' d3 W: N4 P6 e3 U}
) s: @, R) d) H$ p; y- m$ F% O# ]8 p3 e4 ~6 m7 }+ {
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了