|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
" _; q9 n; x$ u, H/ tUse the Item Class Extended Method set to set a new private Permission for an Item.
4 T* n% J4 S! Y: NJavaScript $ P% S" u; b z4 p) M
// Set up the Part query
+ P8 s4 n; o3 [8 M7 i# U% p0 Vvar innovator = this.newInnovator();
) G. n6 @0 H3 ~4 ^var qryItem = this.newItem("Part", "get");
: R0 V7 n, b% q `0 ]* e9 W! ]- ZqryItem.setAttribute("select", "id,permission_id");
) J" m8 r( p% c- b; c, nqryItem.setProperty("item_number", "123-456%", "like");
i- M% j, L2 K6 J1 {& q ) E# r# d2 k0 }' v' N
// Run the query and check for errors
& q- |; _: {9 s. l* `$ N; }4 hvar resultItem = qryItem.apply();
0 u; @* y7 g; s) C( e, \1 t3 @if (resultItem.isError()) {
- G* Y0 j x' g- ]8 ~* h* B" p top.aras.AlertError(resultItem.getErrorDetail());
1 R+ X4 F0 X- w- w0 [ return; K) _$ H1 @5 Q& ^
}
- l3 |0 f) b- g1 W $ }7 y% Z5 L. F% ~0 ]
// Iterate over the Items returned and add the private permissions for each. . w! g2 p& U/ L9 d1 H
var count = resultItem.getItemCount();
' }" V( {4 A8 f1 J8 n5 nfor (i=0; i<count; ++i) { , C8 {1 e. @/ b! B) c3 f$ f- }
var item = resultItem.getItemByIndex(i);
9 l% T$ h2 w9 [; v' s // Start with a blank permission
9 r- y- u8 @' [8 z- i var permItem = item.setPrivatePermission("");
. \! w y+ m* U0 A& K% B) K, q // To copy from the current permission: permItem = item.setPrivatePermission();
6 r2 J* i# j6 z3 g& @ // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
! O+ x" u( G r' R 5 b( t% b q |3 C, b3 P6 }# ^
permItem.setProperty("name", permItem.getID());
+ | d8 V2 ~$ o9 N {. x permItem.setIdentityAccess("Component Engineering", "get", true); 6 e ~% ~6 ~ S
permItem.setIdentityAccess("CM", "get", true);
4 A# G2 C- `' d1 T2 c+ B1 X' I permItem.setIdentityAccess("CM", "update", true);
: x8 {: x- E _- Y, E" v
& F. C$ V; W* Q: |# s // Grant access to the current user's alias identity $ U; N/ g9 X3 p% H
var aliasId = innovator.getUserAliases().split(',')[0]; ) k) d- s' `0 W' C' |8 x
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); 7 H% g5 d1 N, u. C7 L1 J( H
permItem.setIdentityAccess(aliasName, "get", true); : r% x, p5 C. c4 R0 a' c% X2 P: {
1 x0 P1 E4 x; H1 j# s4 {7 a; M6 v4 v* u item.setAction("edit"); 6 R+ _' g' Z& z: B0 q
resultItem = item.apply(); x% G" Y: U" @
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
4 j$ }3 _6 z \} 2 I- V/ m; T# a8 S( L
% d. f( y; y/ u$ s e3 ~# n
|
|