|
|
请使用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 ~ |
|