|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
+ a, p9 j" b9 Q% sUse the Item Class Extended Method set to set a new private Permission for an Item. # X2 o1 H5 Z. f+ U
JavaScript
& D4 ~) a1 N8 o% b9 v0 o; @// Set up the Part query
, M8 i, k, r5 j1 ]var innovator = this.newInnovator(); 7 ^6 M3 x" s8 V$ `) X
var qryItem = this.newItem("Part", "get"); * y! @0 W* L3 l
qryItem.setAttribute("select", "id,permission_id"); 0 |, j: M# f" }+ F2 v- ]% j
qryItem.setProperty("item_number", "123-456%", "like");
& d& o' E" F" H# j ; k+ |9 n8 J+ @* U* ]2 z
// Run the query and check for errors
( [: u! L0 f5 `) H2 avar resultItem = qryItem.apply();
! |1 u/ C9 o* i# }4 Lif (resultItem.isError()) { : J% Q2 \% P3 ~1 R" o# Q' n" W. E2 R
top.aras.AlertError(resultItem.getErrorDetail()); 3 x2 s9 c) W5 b8 I1 h5 N- k
return; $ U& d4 G# Z0 y9 J% p, u( f
} + Z: T- T! K5 Z* ^1 B( ]+ x
: }, P4 ` y3 p% r2 y/ E// Iterate over the Items returned and add the private permissions for each. , b' \" O/ K) `; c
var count = resultItem.getItemCount(); K( _0 y8 ]6 @! ]; O- p5 L
for (i=0; i<count; ++i) {
7 e/ W6 l# q- _' g$ `" ]$ _( l6 _ var item = resultItem.getItemByIndex(i); - w- U) X8 x0 B- x, O' X0 m
// Start with a blank permission 6 o- q' Z$ U/ f# ? e1 ?; s5 h9 j
var permItem = item.setPrivatePermission("");
3 `$ m: d/ N- i; a // To copy from the current permission: permItem = item.setPrivatePermission();
9 V' x0 O9 b6 G+ _, N // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); ( K* M; M& s) c* R; f$ }! Z
/ e+ {% M& }6 ~* G. m. |
permItem.setProperty("name", permItem.getID()); $ d( r$ \/ Z, g. M, o2 ^$ R3 X! A
permItem.setIdentityAccess("Component Engineering", "get", true);
) z' c% S& c6 c3 M% \$ d7 x) y2 i- ? permItem.setIdentityAccess("CM", "get", true); 7 @/ H" Z$ Z, O1 z3 [
permItem.setIdentityAccess("CM", "update", true); m5 j. m. o, b* R3 Y- A/ ^
" m7 V$ h6 l4 a1 T
// Grant access to the current user's alias identity
+ W1 G7 n% O0 ~ var aliasId = innovator.getUserAliases().split(',')[0]; + M" r3 g9 c5 M9 |8 O& a0 T
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
' A \: }# |$ j; d" f! Z permItem.setIdentityAccess(aliasName, "get", true);
2 d* x5 b9 s# x8 ~ a1 y/ I7 y ! Z% q* u6 B. ~3 j
item.setAction("edit");
, W$ t6 I7 Q M0 {3 [7 Y; | resultItem = item.apply();
2 q0 _: M( P8 P9 n0 J( x7 ] if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
5 \# C# d4 M5 \$ G4 }; [} 6 I' I# {! H* e
/ r; y6 O' d2 c% ? ?0 P# Z! H# [# d
|
|