|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique ( [8 {% T2 T( m, f. A. [1 D. @
Use the Item Class Extended Method set to set a new private Permission for an Item.
: ?" H. t |0 a8 A* }. |JavaScript ( h& O) P( f8 s1 Y' @: q+ N2 c
// Set up the Part query
' U( x k' y* X* U' tvar innovator = this.newInnovator(); 3 h0 H7 H4 i5 ]) ]3 [7 K( S
var qryItem = this.newItem("Part", "get"); . H. f& ^" i$ p
qryItem.setAttribute("select", "id,permission_id"); " A% J1 J, }3 Z2 `
qryItem.setProperty("item_number", "123-456%", "like");
; V! k+ K8 G* ^9 ]- v% u- W 8 T7 |+ H( R2 |
// Run the query and check for errors
! C8 ?% h2 [3 o6 G# _1 I9 u! avar resultItem = qryItem.apply();
/ w/ n* t# C2 E$ uif (resultItem.isError()) { W; ]- [& y4 \2 d! Q. R, e7 j, p
top.aras.AlertError(resultItem.getErrorDetail());
4 h$ a: k" E2 X, L" [ return;
" |9 ~3 y( V+ x9 L# A} / K, \( _; G! U# F5 u* U
1 Q! `! s. R6 {+ G7 `( }
// Iterate over the Items returned and add the private permissions for each.
2 e& @! A9 }& V6 E& m' b, bvar count = resultItem.getItemCount();
0 K. ]. ~/ d6 L# W: |& Wfor (i=0; i<count; ++i) {
) U8 C. h1 ]6 A& u& T/ X; a var item = resultItem.getItemByIndex(i); / C5 W& R0 P% h% t. V( Z" h
// Start with a blank permission
4 ^$ |6 w$ ]9 Y' S( Q% Z/ u var permItem = item.setPrivatePermission("");
# l' y' b% z1 |/ L // To copy from the current permission: permItem = item.setPrivatePermission();
! c. L E `8 S9 {0 h // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); . ^4 @) z) V* r5 H" U7 H
& A2 h2 f: @; T permItem.setProperty("name", permItem.getID()); 8 X& b# z; W: ?. z
permItem.setIdentityAccess("Component Engineering", "get", true);
% z6 U% G2 t/ w$ i9 n" H! r( ] permItem.setIdentityAccess("CM", "get", true); + F6 Y& v5 }; B$ R
permItem.setIdentityAccess("CM", "update", true); 7 A" n* E: w2 w: q
0 A. F1 B, G6 K+ g" H, O# D // Grant access to the current user's alias identity % ]" T* o( E9 X b# d
var aliasId = innovator.getUserAliases().split(',')[0];
. A w3 r% p# \ Z5 z. a& z var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
7 C7 N' _" f9 ]' ~9 j* `% x7 B permItem.setIdentityAccess(aliasName, "get", true); 5 b* P+ \0 c# C+ G
' R) H7 S& q' ? item.setAction("edit"); - F* G& _3 C# v
resultItem = item.apply();
, D _ y3 Z5 E$ |) B3 T. y5 e if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 8 `4 @& A1 E1 L" G
} 6 O- ~8 Q- A% [ L& ?) Y' X
! V4 Q2 \, z' o: b6 S |
|