|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique - g9 _1 L$ t9 U7 f5 R
Use the Item Class Extended Method set to set a new private Permission for an Item. 8 B0 s1 y V3 F/ F" @- N( I3 O' [
JavaScript
3 D' H$ T) D+ s- k; W1 T// Set up the Part query
- B4 b/ A7 S: }" j5 Q9 P* Pvar innovator = this.newInnovator(); % Q$ [) n% i4 }4 f; j
var qryItem = this.newItem("Part", "get"); 5 B+ P: M$ O' y5 Q
qryItem.setAttribute("select", "id,permission_id"); , X' O f. E- j. q2 E
qryItem.setProperty("item_number", "123-456%", "like"); / \- a- t' X2 k
5 h n- `! |7 ~1 |/ J+ _5 D
// Run the query and check for errors 7 k: O* S2 f6 H+ r8 i
var resultItem = qryItem.apply(); ( \- `& c/ F2 G H+ }0 R8 K
if (resultItem.isError()) {
$ f( @ g: N2 E( w top.aras.AlertError(resultItem.getErrorDetail());
# f9 e5 \4 s3 d return;
! Y, u; ]$ Z6 O}
, C) b, x8 J1 K: b+ x $ `0 u, y Y; R1 }) k* T
// Iterate over the Items returned and add the private permissions for each.
$ z' q" [- s" W' p3 a6 @var count = resultItem.getItemCount();
! {2 Z, ]# }- _# Y; }+ f) U+ ofor (i=0; i<count; ++i) { 5 I' z$ @0 `4 P* X% X/ I
var item = resultItem.getItemByIndex(i);
0 s; r& Y2 V5 A8 K; R // Start with a blank permission
/ R' k, T# |9 b+ s% a var permItem = item.setPrivatePermission("");
- v, e9 ?( Q. A; a // To copy from the current permission: permItem = item.setPrivatePermission();
) G( b# e5 C9 o( r N) s // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
$ {% ~7 Z! T& I
, ~" s4 J; ]$ m! u permItem.setProperty("name", permItem.getID());
0 e/ {0 A% L0 Y4 C$ j& Z permItem.setIdentityAccess("Component Engineering", "get", true); $ x7 }- y) w" W$ D
permItem.setIdentityAccess("CM", "get", true); 0 h; i+ l" Y0 X9 h% T' Y; {
permItem.setIdentityAccess("CM", "update", true); " F' |2 l: I# f! x" ~/ E! f
, A1 H$ E; C6 M) j4 ` // Grant access to the current user's alias identity
* C, k$ V: [/ H5 P1 Q1 Q var aliasId = innovator.getUserAliases().split(',')[0];
5 a& E* r6 }; S4 _3 X' ~; f2 F var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); % q( G! E! y3 }8 Y
permItem.setIdentityAccess(aliasName, "get", true); ( L$ c+ v9 v* \* Q
/ a. c& L8 [5 S8 L# a item.setAction("edit");
' q+ `6 h* P3 `1 h; c9 v+ n G/ a, k$ b resultItem = item.apply(); 9 d7 U5 ?. Z2 z8 h4 F
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 6 G& ]) `( i% \# w! s
} J+ _# T, e) B( Y" c% b" }
8 W+ n) I: l; n! a0 y |
|