|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
Technique
. r& S3 j* l& T& P8 W4 n( I6 VUse the Item Class Extended Method set to set a new private Permission for an Item.
# E6 L- e" p4 R3 K9 _JavaScript
9 `" c: T0 ^: J+ J// Set up the Part query
* ]0 v8 {3 z+ ?) {var innovator = this.newInnovator();
: K& [ b6 N4 t3 N/ J+ Dvar qryItem = this.newItem("Part", "get");
( t- J5 R0 j6 M" {; B! O/ @qryItem.setAttribute("select", "id,permission_id");
$ Q0 ?1 b5 G7 j2 T n2 \qryItem.setProperty("item_number", "123-456%", "like");
( b. U- w' B" D9 C# e9 \
G0 L0 E! c4 s: D1 w+ Y, u// Run the query and check for errors
6 v+ S- b \/ T! L6 K6 ~var resultItem = qryItem.apply();
5 j, x2 R% V6 N6 r3 pif (resultItem.isError()) { 4 s2 B: N6 ~+ _
top.aras.AlertError(resultItem.getErrorDetail());
, N: n3 }7 l; \; x return;
1 V3 d M0 C0 i& m" O1 G; `}
* [- B" y" ~6 u- s. n" G
% p5 I. ]7 C9 N; b) f# B// Iterate over the Items returned and add the private permissions for each.
' _$ W3 t2 M) Y8 n3 O1 |* Mvar count = resultItem.getItemCount();
: x& d) z' c* ^$ e* @$ y& |- Y1 m5 yfor (i=0; i<count; ++i) {
/ ^! v+ n& X" l7 [9 _' k8 I. f% K var item = resultItem.getItemByIndex(i); " h1 r* @/ i1 a0 Z* z' Q
// Start with a blank permission 3 {* Y; Y7 I1 o5 N* G) e) S
var permItem = item.setPrivatePermission(""); 1 D1 s' Z7 w3 ]' e& S
// To copy from the current permission: permItem = item.setPrivatePermission(); 6 y2 x! W; z, H- P. j6 Q
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); + Q5 N/ Z% \0 x% d# Y- R
2 S5 j3 P2 x- y
permItem.setProperty("name", permItem.getID());
, g) F4 S0 b4 G, y permItem.setIdentityAccess("Component Engineering", "get", true);
, x* O3 G8 u3 W* k6 X' N permItem.setIdentityAccess("CM", "get", true); ) @4 _1 S9 v' P
permItem.setIdentityAccess("CM", "update", true); 1 }# K b, X4 ?0 R0 H
u1 O! S9 v* W7 I
// Grant access to the current user's alias identity
% T/ c$ W' e0 k. O) n8 E var aliasId = innovator.getUserAliases().split(',')[0]; ( I! ~" U+ z% n* |: J9 t) P
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
8 Q( D3 V, K' C& b% O permItem.setIdentityAccess(aliasName, "get", true); * D' L9 v: X+ }6 \2 n
* B0 y7 P6 q& T# k% R
item.setAction("edit"); ( ?5 b( z: A, r
resultItem = item.apply();
; n, [! Z7 D A8 S$ S3 t if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
z% Z! X( V& J+ F# o9 R}
/ U9 H0 J3 G7 L- V8 m
* F7 l4 j; M4 V9 C+ A |
|