|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
Technique
Y# |9 ~+ }" ]) s. |' MUse the Item Class Extended Method set to set a new private Permission for an Item. & {* l( w# x6 j" S1 Y/ T
JavaScript
S* j S. \4 W// Set up the Part query 1 U1 V& P3 p. P' w3 I0 z
var innovator = this.newInnovator();
2 P+ s* _& |' k fvar qryItem = this.newItem("Part", "get");
9 ]/ C& w7 z% i2 _& y, ~0 m; \qryItem.setAttribute("select", "id,permission_id"); 3 C) P5 j' b$ l: |$ ]
qryItem.setProperty("item_number", "123-456%", "like"); 5 y( }1 q D1 [2 b7 t9 f
( h! v' W# D# M/ D5 h1 A3 d% M// Run the query and check for errors 3 N6 ], a$ I: X1 b9 ~
var resultItem = qryItem.apply(); / U7 L5 V) u. y* S7 L
if (resultItem.isError()) { 0 v. z$ [; x2 [* w5 j/ E+ L/ E8 B
top.aras.AlertError(resultItem.getErrorDetail());
9 o h3 ?! Z K return;
8 f8 l8 A K8 S' J4 \0 r- {& _} * T% }. e# y- D% f5 Q
' L4 p0 E3 _! W# P
// Iterate over the Items returned and add the private permissions for each. # }2 [' d- m6 I
var count = resultItem.getItemCount(); t8 J; m9 b$ F8 g5 g1 H
for (i=0; i<count; ++i) { & c" }+ ^* Y; w# d9 m
var item = resultItem.getItemByIndex(i);
7 {2 n" `5 ^4 E/ V8 [! i // Start with a blank permission . n* a& Z; L9 }5 Z8 |
var permItem = item.setPrivatePermission("");
) z' ?# P6 _' h // To copy from the current permission: permItem = item.setPrivatePermission(); 5 C! Z& Q6 Y) W/ B% e( W6 X( z7 h1 {
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); # h- b5 Q; ]; Z
; i7 ~8 v9 }3 U, v+ R
permItem.setProperty("name", permItem.getID());
# r& }! r1 R! `. ^* M( r permItem.setIdentityAccess("Component Engineering", "get", true); % R" O/ b& d0 h. v- E# b
permItem.setIdentityAccess("CM", "get", true); + l ^: B! w8 t, h; }
permItem.setIdentityAccess("CM", "update", true);
" c' ~! E& t; O# s" T5 ]6 a. s ) I( T: D4 D. R4 k! t, Q
// Grant access to the current user's alias identity
$ e7 ~: o# e' ~( P5 z/ Y* z: ~ var aliasId = innovator.getUserAliases().split(',')[0]; % ?) L+ ], q5 K! A$ w
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
5 |1 b% |& I( Y6 D: r permItem.setIdentityAccess(aliasName, "get", true);
! D9 b! R5 J$ g. c
) e4 b: X O1 z; [$ p7 F! t+ H; X item.setAction("edit");
F6 b9 C* m, b$ A9 | resultItem = item.apply();
4 r. i& ~( M& L4 `& b+ D if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } % A1 [6 x2 W' \
} * n! g; L: _0 \, j8 C% [% R" `
) ?; p* V! ?/ A8 Q |
|