|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
3 z9 }- f n) P% @Use the Item Class Extended Method set to set a new private Permission for an Item.
9 @# y1 x; W/ T6 zJavaScript 2 [. ?0 ~/ u3 U( x: n+ z
// Set up the Part query ( q7 N% U8 Q0 \( ^7 S: G
var innovator = this.newInnovator(); 2 v6 \/ _4 y4 _! Q$ _8 L
var qryItem = this.newItem("Part", "get"); , I4 w. X+ d- @3 s5 A
qryItem.setAttribute("select", "id,permission_id");
2 T: b) ^; q2 V, l1 U0 EqryItem.setProperty("item_number", "123-456%", "like");
+ o/ h0 o- ` u2 ^; ? 6 Y0 ~! L- ^* Z, J
// Run the query and check for errors * @( O0 q' }/ P7 P2 u
var resultItem = qryItem.apply();
3 F1 ~* C4 \5 Y( t/ \if (resultItem.isError()) { . u: ?) A3 p1 Q: \0 ~3 X
top.aras.AlertError(resultItem.getErrorDetail());
2 C5 J( k6 L9 v3 M! E3 i return;
5 i& v9 ^! e2 s, o" p}
3 k3 j+ V! c+ i) ? 4 I; t/ y7 M W' D2 r
// Iterate over the Items returned and add the private permissions for each.
2 X2 j$ n, l. ]% o& jvar count = resultItem.getItemCount();
- ]4 r; i" M+ [- s% E C: x) Rfor (i=0; i<count; ++i) {
2 p% z, D0 r$ ] c1 F: c2 _8 P var item = resultItem.getItemByIndex(i); : m! D6 Z: @& r, i; Y7 y' t, n
// Start with a blank permission
5 b7 }! T: a) O# }# I! r var permItem = item.setPrivatePermission("");
7 F% k+ I: E1 ~; I- U7 F: X // To copy from the current permission: permItem = item.setPrivatePermission(); 1 A) q; v8 Y8 O. H
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
9 W$ e) z( n5 B; {; k- u
! }% T: a# ~' o. s" M" H/ s6 v permItem.setProperty("name", permItem.getID()); 0 b" s: g5 N: x! S& I0 p
permItem.setIdentityAccess("Component Engineering", "get", true); ' _8 Z/ c) X9 }# g$ L
permItem.setIdentityAccess("CM", "get", true); 5 p8 ]% w6 f% |9 l- S* u
permItem.setIdentityAccess("CM", "update", true);
+ i' I( o7 a2 }; G- s
' ?( ~; a1 e+ B5 X! R7 j4 B // Grant access to the current user's alias identity
9 b% r' P, q) b6 c2 l var aliasId = innovator.getUserAliases().split(',')[0];
& A$ G. y# B5 C3 N1 X& v) c1 ~ var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
0 h- A5 a @+ i7 X% W O2 y8 Y permItem.setIdentityAccess(aliasName, "get", true);
& w* t( U2 f; W: _0 M 7 f2 T. y/ }: t
item.setAction("edit"); : `8 b$ W. k' b0 K) m0 G" M
resultItem = item.apply();
" H8 Y0 j7 Z/ I4 t" h$ x if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
! j" G% j; G/ l. W0 k8 {+ L}
# e$ ?# S9 Z9 h4 I. h. G6 ]
: Y( [2 O/ v2 c+ r, K |
|