|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
! L# `. d) M! ~& |- I4 R" B; IUse the Item Class Extended Method set to set a new private Permission for an Item. 2 P C! e: h- O) k5 m
JavaScript 9 _9 ?& I( \7 L! |' `
// Set up the Part query
9 [1 w6 R" t' s+ a+ Q, jvar innovator = this.newInnovator(); 3 g+ i0 r& \. ^5 I2 r7 f' p
var qryItem = this.newItem("Part", "get"); A" a6 p8 C# w
qryItem.setAttribute("select", "id,permission_id");
* z. f. U+ e- aqryItem.setProperty("item_number", "123-456%", "like"); B) X8 S& U1 \
' m' L+ B8 T! l, v
// Run the query and check for errors
, [! }+ i' D" i9 g7 V3 @ qvar resultItem = qryItem.apply(); 3 d/ z0 p2 K, M$ D( M, n
if (resultItem.isError()) { * b$ d) Z$ H$ g
top.aras.AlertError(resultItem.getErrorDetail());
% e9 X- `/ h/ {3 V/ ? return;
) |. V" S* X+ E3 u. r9 [}
+ Y' j9 L, Y7 | 1 Z- c& [+ G7 @: q# @9 H' E1 Y1 {
// Iterate over the Items returned and add the private permissions for each. X* z4 r6 U d4 i9 k' F4 U8 v% a
var count = resultItem.getItemCount(); . n6 G4 S. C# F: _
for (i=0; i<count; ++i) { # L" z$ Z$ _, m4 A( L9 P
var item = resultItem.getItemByIndex(i);
" Y: |3 k1 K7 y8 n8 w // Start with a blank permission ! L2 v! Q# f; ^ |8 D+ Q; M4 r% o6 ]
var permItem = item.setPrivatePermission("");
0 A6 ~& S! q+ l& ~& M // To copy from the current permission: permItem = item.setPrivatePermission(); ( a: n! n s$ p7 g' s
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
% e6 L- v$ p" |* x# s L
9 M( n0 z$ G7 |; M! [ permItem.setProperty("name", permItem.getID());
J- ~# v5 m# V4 ] permItem.setIdentityAccess("Component Engineering", "get", true);
/ z0 Y J0 P; _% v0 W; [ permItem.setIdentityAccess("CM", "get", true); : m) A! Q. b7 O# K D
permItem.setIdentityAccess("CM", "update", true); , G2 N2 T- M' u5 ?% s
. t; ]" a+ C! d; A9 z0 J // Grant access to the current user's alias identity
& u: p$ ?; ], k7 f, z" ~; a& `$ ?( v var aliasId = innovator.getUserAliases().split(',')[0];
& t, z- U0 x+ B* Q! `5 g' b var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
3 I4 Y; N, }: I; z permItem.setIdentityAccess(aliasName, "get", true); , F; k* {3 t4 `* W3 @* Z: W, H$ c
) s3 u% ?$ \4 s6 ?' ]
item.setAction("edit"); 6 f* Q. j. L; W7 V& @1 x9 a
resultItem = item.apply(); $ w' T' t' b4 M( u/ b
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
3 z3 [# i0 K5 T& Y# X$ k} - O( W) D' l. r0 T
S# C* G* \$ q+ k. i8 Y8 }. e# ]9 A |
|