|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
) \( @7 f! u: j- M7 l2 P. cUse the Item Class Extended Method set to set a new private Permission for an Item.
9 f6 x+ H! ^) l) c; J0 SJavaScript 3 ]; {2 o2 J. W
// Set up the Part query
) W8 k2 m9 M" E$ K* ]var innovator = this.newInnovator();
( V+ ~. B0 B9 Q2 p8 X ovar qryItem = this.newItem("Part", "get");
3 u9 R1 C' k- O- a9 Y. cqryItem.setAttribute("select", "id,permission_id"); . X/ W! j9 o. g' d" c
qryItem.setProperty("item_number", "123-456%", "like"); 1 @& J5 S; l+ Y5 w. ?% u
$ l' i* D$ E+ ~0 B6 v1 [// Run the query and check for errors
9 k& R" Q3 {9 { f- ]var resultItem = qryItem.apply(); * k$ \5 H* G0 ^& S
if (resultItem.isError()) { * B& {3 t2 A1 ?9 P0 I
top.aras.AlertError(resultItem.getErrorDetail()); 7 J# X7 @% Z7 M; I# e
return;
. c/ @4 L* O9 v( P}
: p% E K0 `% ~4 n( Q
5 O+ y( R) J( G0 h/ C7 O// Iterate over the Items returned and add the private permissions for each. * O8 o6 T1 i4 a H: k
var count = resultItem.getItemCount();
. k% P1 G2 \/ A# T% pfor (i=0; i<count; ++i) {
/ x1 s2 S9 T8 H, L/ { ~ C var item = resultItem.getItemByIndex(i); ! H" o7 ~$ e; _/ i$ p' j
// Start with a blank permission
8 S7 a5 m1 L2 @ K3 m1 O var permItem = item.setPrivatePermission(""); % Q; J) h* o9 s
// To copy from the current permission: permItem = item.setPrivatePermission(); 5 s& ~' _4 U0 o* ~4 f0 r
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
# W0 R: p4 t8 A \3 g* k# ]
' ]9 V9 A; h: b4 f3 h1 I permItem.setProperty("name", permItem.getID());
6 R" ^# H- G5 j permItem.setIdentityAccess("Component Engineering", "get", true); 9 s8 k* R J# M& T* h& B2 W
permItem.setIdentityAccess("CM", "get", true);
( O ?( G7 W! Q: U permItem.setIdentityAccess("CM", "update", true); $ L" |- d, a; y/ A2 w: [
8 X7 {7 E' T0 x" A1 X1 X* W
// Grant access to the current user's alias identity : e, e3 q# k8 ?# W4 `2 D& T( @
var aliasId = innovator.getUserAliases().split(',')[0]; " d' ~2 ~% A% R0 H; G& z6 ^
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
0 l8 k8 {! r1 I0 |9 j) p permItem.setIdentityAccess(aliasName, "get", true);
1 ?2 F3 h u: x4 b2 r I& E* \
3 F4 }$ W, z+ ]+ R8 X7 G item.setAction("edit");
3 ^$ [: v4 l9 x+ d# k2 T resultItem = item.apply(); 1 i5 I. A3 L) ~" M; I8 Q
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
: Y' `7 Z$ U; C' e4 R" R) k}
2 D) a$ y, W9 K0 j6 m, Q! A4 t1 G1 }2 G; P
|
|