|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique 5 Z6 K4 k O; G$ i/ c
Use the Item Class Extended Method set to set a new private Permission for an Item.
2 a" J7 P' Q- i3 f1 tJavaScript " a* h; @8 L9 X, P/ y% K
// Set up the Part query $ Z3 S9 a) Z J, y! P5 u
var innovator = this.newInnovator(); 1 F% \* R8 C W) [2 o( y+ T. O9 E
var qryItem = this.newItem("Part", "get");
# ~8 E% W) b4 S% x: UqryItem.setAttribute("select", "id,permission_id"); 3 p2 V0 b- A l: _
qryItem.setProperty("item_number", "123-456%", "like");
3 Y* _ U. f& {9 Q A
8 ^ P* z7 y1 D+ @// Run the query and check for errors 7 G! s3 n: C% U# u0 d1 l* N
var resultItem = qryItem.apply();
$ M* U, D+ `& J* p& p7 [* Iif (resultItem.isError()) {
8 x5 J- P7 d2 F3 I top.aras.AlertError(resultItem.getErrorDetail()); ~, {" r" V/ F$ A2 w* j) o
return;
( Y0 I, Q( X! y0 H |. s} 0 v: F% F; C% l4 v. w( B
7 m! m+ U6 E7 J0 q/ P" u// Iterate over the Items returned and add the private permissions for each.
- G J4 c, o! avar count = resultItem.getItemCount(); 9 |0 S7 P& e; G9 k1 f
for (i=0; i<count; ++i) { ' n# D% Y* H1 m, |; \' M
var item = resultItem.getItemByIndex(i);
( ?( E- s& H- K* h // Start with a blank permission % I' z' W. j( P, n; d0 q
var permItem = item.setPrivatePermission(""); ! s9 X$ X0 x5 u) `
// To copy from the current permission: permItem = item.setPrivatePermission();
$ Z1 U- Z/ q- I( R* d) G // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
' Q p% D" {6 P % D' a ]) V' x2 m
permItem.setProperty("name", permItem.getID()); - @! Q( x+ k y: L+ ?; P' x. [
permItem.setIdentityAccess("Component Engineering", "get", true);
8 q5 @8 u2 u* k6 n4 H permItem.setIdentityAccess("CM", "get", true);
; x, Z% d2 P' m! V permItem.setIdentityAccess("CM", "update", true);
( |- j" F1 o' a3 V0 _+ k 1 f5 S. D0 {. h. [
// Grant access to the current user's alias identity 6 @# f! ^3 A; P! I8 D
var aliasId = innovator.getUserAliases().split(',')[0]; ` L( ?; j% ]6 M4 @% B
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ' r* `1 y6 [, |! c
permItem.setIdentityAccess(aliasName, "get", true); $ M' }+ W( c: |* W
# I/ d2 Q8 G0 q) ~" O/ E
item.setAction("edit"); , ?2 \, }) I7 F/ y+ ~; e7 Q$ I
resultItem = item.apply(); 4 @$ ^1 f. c4 q( o
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } ( Y* T% K" H+ V: t
}
; L2 _9 T/ i( a& A* u; ]6 {3 S
7 _0 P! v0 \% K0 T C$ | |
|