|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique 5 q7 _0 S x; d* \0 @, r
Use the Item Class Extended Method set to set a new private Permission for an Item.
/ ~) E( m: ~2 L( i2 `JavaScript
( Y% q* r$ D' [1 y$ q) K// Set up the Part query
5 S/ {! E% L; ?8 q/ Q5 _; Nvar innovator = this.newInnovator();
+ ~! j4 x* }; h5 evar qryItem = this.newItem("Part", "get"); 7 c- t2 Z6 ]6 N1 L
qryItem.setAttribute("select", "id,permission_id"); % W! {5 @: s) d8 @8 F
qryItem.setProperty("item_number", "123-456%", "like");
' R: a Z. D% C) t+ E; v 4 w' X8 ?9 O8 R
// Run the query and check for errors
k" z O; V, i; ~0 I$ Ivar resultItem = qryItem.apply(); 8 ~3 p3 E- X/ M' H" ~; E- ?
if (resultItem.isError()) {
0 f- \4 r( }3 P$ r top.aras.AlertError(resultItem.getErrorDetail());
0 h6 V& D" ]" c' q3 N return;
f$ Q% D, y: M7 e} ! a: { u" t0 V" Z! w7 N# \; {
" f# E( s* _* c& w8 v7 c
// Iterate over the Items returned and add the private permissions for each. 7 ^" B% A' v! [( Z# W
var count = resultItem.getItemCount();
: Q! K2 r0 Y( ~7 ~for (i=0; i<count; ++i) { _3 n D8 O4 n
var item = resultItem.getItemByIndex(i);
2 v! c) g" F( X4 W // Start with a blank permission / S9 A$ v0 `8 F* R0 f
var permItem = item.setPrivatePermission(""); $ d) ?* e( z. P4 k* T! U6 `" B
// To copy from the current permission: permItem = item.setPrivatePermission();
- o& F- X* t$ @4 L6 c( ] // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
* j, H# \% |( r9 _' l 2 s, q0 B' V2 H; H5 Y$ k
permItem.setProperty("name", permItem.getID()); . w0 H8 h" h% w- [$ G+ G; P7 A
permItem.setIdentityAccess("Component Engineering", "get", true); & J) T5 [* H& F2 d
permItem.setIdentityAccess("CM", "get", true); ' R0 |1 ~. q1 g# d2 [9 c* p
permItem.setIdentityAccess("CM", "update", true); ! W1 |" h% V% u
R" o! ] Y/ m% G- H2 w/ P // Grant access to the current user's alias identity
5 [4 j( m( K& |/ _$ B var aliasId = innovator.getUserAliases().split(',')[0];
9 c( t3 i6 p( j- I var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ' g$ ~% z$ M' M: @7 }0 k* r
permItem.setIdentityAccess(aliasName, "get", true);
6 D0 X' t$ |8 U, B 1 o% a* k( Y [% Z$ U& n" I
item.setAction("edit"); 4 S$ j% d* X( q& j. `
resultItem = item.apply(); % {6 y! p) }. p- w ^ ^1 T
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } , O- D$ E1 k% Z5 x0 N; H4 y# ]3 F
} 0 m, ~0 R4 ?. N6 J
8 T; Y. ` s2 Q1 k8 k7 g. z |
|