|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique 7 k R$ W$ O* f4 Q
Use the Item Class Extended Method set to set a new private Permission for an Item. * ~) z8 {9 Z( r$ x
JavaScript * U) \: G& j% T7 I' W
// Set up the Part query - Z1 s y8 o# ]8 d$ H$ y
var innovator = this.newInnovator(); , x* x# }$ Y, U! D8 T6 B
var qryItem = this.newItem("Part", "get");
8 K8 N0 T H( k1 IqryItem.setAttribute("select", "id,permission_id");
! D! ?& a: K2 v8 S; |qryItem.setProperty("item_number", "123-456%", "like");
3 g& {/ l, h1 i) V
* q% T m, T2 t1 P7 q! V// Run the query and check for errors . Q3 \2 ~. Q& M4 G5 [
var resultItem = qryItem.apply();
- t! U/ g( u' `' {5 _# x. Lif (resultItem.isError()) { 3 _* x, i; {- n0 l% ] q
top.aras.AlertError(resultItem.getErrorDetail());
& |- v3 m7 a" H; L return;
. Y$ D. U8 m$ Y' E. n} , A5 f C4 @! m9 G
4 o8 @4 y+ G2 K O* J9 c+ e& o// Iterate over the Items returned and add the private permissions for each. + C2 N) u( ~* m, L3 U7 F
var count = resultItem.getItemCount(); # h+ C0 U; Q6 j9 e3 X2 o3 q7 q! y
for (i=0; i<count; ++i) {
! }+ B" H7 T: m! R var item = resultItem.getItemByIndex(i); 1 V, F' ^1 P% B. C* T2 r
// Start with a blank permission
) A! p. {9 E5 H) X3 B# L- _" |+ x) I var permItem = item.setPrivatePermission(""); * {- }& s' j7 x8 l6 x+ X5 x! u, S/ l$ i- Z
// To copy from the current permission: permItem = item.setPrivatePermission(); 9 V" h/ a! T5 z- U( T
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); : ]. I2 A9 Y! d: C% Q% r. p
$ X. R1 y( L$ X: z" c- g* ^ permItem.setProperty("name", permItem.getID());
" U* z8 u1 A$ @ permItem.setIdentityAccess("Component Engineering", "get", true);
, `% n1 k6 P1 X7 U7 O8 W) l, l4 k permItem.setIdentityAccess("CM", "get", true);
0 b* m5 h7 _3 C permItem.setIdentityAccess("CM", "update", true); % l2 B; w& E9 b0 p J0 i/ h9 i, @; g
/ e$ I6 H1 I- N
// Grant access to the current user's alias identity
8 S; d7 _- Y4 d" Z var aliasId = innovator.getUserAliases().split(',')[0]; % d( K! D$ y5 J5 C. e
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); : `: [* V2 z& _0 y$ ~6 `# n
permItem.setIdentityAccess(aliasName, "get", true);
* o( R8 W4 s* p$ s* k; W ; `8 R2 W% U+ B) c: I, R+ Y# s2 X
item.setAction("edit"); $ f# f" i8 T1 u# |( Z
resultItem = item.apply();
) Y$ Z: P( C) T; L' F5 _1 b if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } ' m- {9 d2 y7 A- q( t" G
}
# m0 `) p5 E t- j4 @% { W* j8 P- b& S8 D0 U+ j- u$ p/ K
|
|