|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
2 s5 ?2 M3 h. ?! m R5 TUse the Item Class Extended Method set to set a new private Permission for an Item. * Y# a4 v n1 o3 L' S# b: D
JavaScript
# Y: e0 g7 b6 G! f: S. U// Set up the Part query
2 ]0 m" n/ P) N' fvar innovator = this.newInnovator();
7 |3 m$ O3 Q/ `5 G2 nvar qryItem = this.newItem("Part", "get");
Y$ Q, E# U. e# u+ FqryItem.setAttribute("select", "id,permission_id");
. v* x. e) e5 B5 y* CqryItem.setProperty("item_number", "123-456%", "like");
' Y+ N1 F$ h- { $ `6 {" D4 v: J# t6 A
// Run the query and check for errors
4 z' ~) w; H- p+ w1 |2 \var resultItem = qryItem.apply(); & l+ t; @! n6 o$ S, r' M- j
if (resultItem.isError()) { P; v4 q& n$ c; N1 W
top.aras.AlertError(resultItem.getErrorDetail()); ( b3 a) V- ]; K6 |; H2 M! t+ p
return;
- q9 ^ g9 Y6 W* ?: o' l( e2 ?} ' e; S& i# X% ~2 q
. n8 `2 O3 R! `7 G4 M// Iterate over the Items returned and add the private permissions for each. 9 g. d: |6 i6 ^: D
var count = resultItem.getItemCount();
* \' U% o6 S1 Y, T/ n! r5 Dfor (i=0; i<count; ++i) { . J5 W/ b5 s, \. d% U
var item = resultItem.getItemByIndex(i);
7 s) k, x; i0 {, F // Start with a blank permission + w+ l( A0 M- H+ x: c# d
var permItem = item.setPrivatePermission("");
+ C! ~" }% Z: r, L: e; D, {( J // To copy from the current permission: permItem = item.setPrivatePermission(); " G! J. T1 i: G. U5 Y8 v" ?
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); - X1 I3 y) x T& w
2 p' d; _- n3 Q! @% N' }! O9 t permItem.setProperty("name", permItem.getID());
8 L% c% M! c; p y' H: c permItem.setIdentityAccess("Component Engineering", "get", true); / C+ y. i& ~2 g. l4 f, ?6 X w) c
permItem.setIdentityAccess("CM", "get", true);
6 q% `: \9 g1 p permItem.setIdentityAccess("CM", "update", true); ) l3 J7 _; @& z+ ?& K$ v/ b
+ m! a' |7 W3 ?7 R$ b- p; S! [+ Q6 G
// Grant access to the current user's alias identity
: T) O0 h: s3 P' E z6 T" [ var aliasId = innovator.getUserAliases().split(',')[0];
. O4 a6 y2 I( F var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); - D+ [$ N! K5 F+ u
permItem.setIdentityAccess(aliasName, "get", true);
& X: y) N0 C2 H8 k( H- _: x % t+ W) M: H7 u' O- T
item.setAction("edit"); ; v( t$ Y0 z. l9 v o
resultItem = item.apply(); . T' K% R; J) H4 q9 m2 I y
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 3 C/ Z: d- I: {# Q& N
}
" ]+ K4 _( F& V- B7 V- N+ c1 w2 c1 y o) ~0 V# [6 q" H* ~/ n
|
|