|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
& D |2 s6 X) \' s; o8 K! ^Use the Item Class Extended Method set to set a new private Permission for an Item. ! n* ?- P! n4 d8 p* [
JavaScript 0 H R5 C0 }- X0 v$ |3 e% `
// Set up the Part query
2 ~/ a# M) j$ Tvar innovator = this.newInnovator();
/ v( P! l6 s# u& ]2 b8 v: Bvar qryItem = this.newItem("Part", "get"); $ Q* |3 f+ |) c7 o, H
qryItem.setAttribute("select", "id,permission_id"); * w9 b4 Q: Z$ @2 f2 O% Y5 A- z/ R
qryItem.setProperty("item_number", "123-456%", "like"); 3 P7 [, v2 V: h% G
/ O- X0 ~6 ^; F
// Run the query and check for errors
4 u( ?" c. y( u- s/ X: H7 uvar resultItem = qryItem.apply();
- U+ j% P+ p1 y: h: ^if (resultItem.isError()) {
. f1 f3 D4 x! }4 J0 A0 b top.aras.AlertError(resultItem.getErrorDetail()); 4 |) W) R0 d# |/ C1 f# S' D
return; / P: G9 B" \$ ?7 U. F! k( i
}
! O" g; L8 f5 ~( H+ B 1 R2 b U2 f" n6 b2 h& ~ q0 f' m
// Iterate over the Items returned and add the private permissions for each. / n R% P6 x+ s; `' d: V
var count = resultItem.getItemCount(); ) k/ j6 D/ N. z" C, r+ l5 v U2 F
for (i=0; i<count; ++i) { / j% n, J1 U: f& T z
var item = resultItem.getItemByIndex(i);
4 R% `7 P6 S2 v7 R( H // Start with a blank permission - s' M" }4 p% E. O4 j5 b7 J8 t
var permItem = item.setPrivatePermission("");
! o; A+ j2 q' W // To copy from the current permission: permItem = item.setPrivatePermission(); 6 \" _0 i; \; z) F
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
9 w% j7 {5 t: M1 ]- p$ s$ d 1 `" S! I7 A& O7 O; h1 i
permItem.setProperty("name", permItem.getID()); ( T% S% m( ^ H$ R1 x
permItem.setIdentityAccess("Component Engineering", "get", true); % \: i4 Q; G. K ^: x) I
permItem.setIdentityAccess("CM", "get", true);
, b" q) l, p u0 C: Z: p/ D permItem.setIdentityAccess("CM", "update", true);
) u8 W3 K$ L7 }' x $ k6 p" U) X0 p9 Q5 g2 @
// Grant access to the current user's alias identity
3 l+ C8 n: l* p3 Z var aliasId = innovator.getUserAliases().split(',')[0]; 5 c/ i$ V* S6 b, R( c- v
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); 4 R* j5 @/ f" B/ G" ?# Z
permItem.setIdentityAccess(aliasName, "get", true); o7 D; L( N4 {- T0 t- A
% Y' U2 d" L' V8 j" R- B2 O7 ^
item.setAction("edit");
9 i5 Q1 b2 s8 L' o9 n1 H resultItem = item.apply();
, r/ p" p9 H* Y. T! R/ S5 } if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
4 x9 E$ G) V3 G9 P/ v/ k w3 [} 0 k5 t- _' n6 j. y* u. n1 X
$ ]) b1 x1 d* T6 M, J! ]2 J: d; x8 z
|
|