|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique ( {8 J, d# S& B0 y1 t% w; y
Use the Item Class Extended Method set to set a new private Permission for an Item. 8 E, ]: E, |2 @" V
JavaScript 7 @ z2 x4 k/ t5 p' o- f2 q) ~2 z
// Set up the Part query
( m3 u v2 Q6 J- W! ^- U- a( P9 zvar innovator = this.newInnovator();
) j# H, U9 [+ x: Evar qryItem = this.newItem("Part", "get"); $ s* f, J! u- W, x
qryItem.setAttribute("select", "id,permission_id"); 4 \3 Y2 L2 U. T) q! H
qryItem.setProperty("item_number", "123-456%", "like");
/ k, |" `6 ~8 _
" S2 s" h. \. s* d: b, \3 _// Run the query and check for errors
H1 u( Y) F ]4 f! tvar resultItem = qryItem.apply();
) h# o/ Q! @) ~. S* H4 z \if (resultItem.isError()) { ) }: l* g( a. ?9 f( b6 U- p
top.aras.AlertError(resultItem.getErrorDetail()); 5 i' Q$ L4 u' U; Z8 S* R
return; + y' ^, R1 K7 j) u
} ! g' H y, {: x* N4 S
( Y! N9 i6 O; g# f ]/ X% e' |
// Iterate over the Items returned and add the private permissions for each. $ l( N$ m& L5 i; E" K h" {
var count = resultItem.getItemCount(); $ J2 H; B, I7 y8 p0 h6 E* i% D3 d
for (i=0; i<count; ++i) { 4 z' Z- [1 q+ K1 I8 E# U+ Y# ]
var item = resultItem.getItemByIndex(i); 7 q, x9 X, D3 t
// Start with a blank permission 3 h8 A6 R$ l$ b: v0 d0 P7 k
var permItem = item.setPrivatePermission(""); / ?& N4 d5 k! }# o; E2 s
// To copy from the current permission: permItem = item.setPrivatePermission();
$ o% [1 @! [8 ^! w' g+ }) ] // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
/ {; k* _: J% l5 W5 A) K
u; F6 t. I Z4 K permItem.setProperty("name", permItem.getID()); 6 Q- c: U. l. }" @2 \: K" N1 j Q
permItem.setIdentityAccess("Component Engineering", "get", true); 1 R9 V- R, A! c5 {
permItem.setIdentityAccess("CM", "get", true);
! n: B6 R) `. f2 {% Y permItem.setIdentityAccess("CM", "update", true); / y: ]2 ^9 \3 m" c ?
+ ?) U- F" h# V, `
// Grant access to the current user's alias identity 9 d# N s1 Y; Z; T, ~0 q [% M- a
var aliasId = innovator.getUserAliases().split(',')[0];
7 I7 i7 d7 K% q% m, e& Y* y var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
: r2 M( j& M$ Y) _' { permItem.setIdentityAccess(aliasName, "get", true); " M! }. T& k) \2 X
* w$ V0 _. w# A+ U4 U0 K
item.setAction("edit");
9 Y4 h! e8 u. O* l1 W1 I" m% w resultItem = item.apply();
2 I3 V- ~/ C# C6 v- D X if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
* A9 U! M; x) K9 V4 \1 A J s}
( o7 ~, W# ]7 [5 [" `9 F Q
3 I# m* n* A* W4 _' t |
|