|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique * _) S1 p/ ~8 ]
Use the Item Class Extended Method set to set a new private Permission for an Item. $ @1 _/ _4 s, v; n8 Z( z/ \
JavaScript
/ r6 O# C% R$ J// Set up the Part query
$ L- B( ~) X7 |! i: {var innovator = this.newInnovator();
1 F+ i0 U- o+ U+ F! Jvar qryItem = this.newItem("Part", "get");
% B7 V! j( I# C# ~6 R3 I; UqryItem.setAttribute("select", "id,permission_id");
/ f) s4 w, j5 _8 a2 S. ~qryItem.setProperty("item_number", "123-456%", "like"); / \+ l; q" m$ p
; i* k8 o+ S$ J7 @( x( Q0 b
// Run the query and check for errors 2 f: E# S0 o W, z- y# r0 R$ `* H
var resultItem = qryItem.apply();
2 J3 }% G; S q. C( J" R# N: dif (resultItem.isError()) {
, b7 q6 U8 s' g top.aras.AlertError(resultItem.getErrorDetail());
2 j9 y7 U8 g( y- |" n, l/ Z return;
C( B5 O P0 q9 d( r}
8 f% E5 l5 N7 L; H2 Q
: p& t' N* W1 t$ P* f8 I// Iterate over the Items returned and add the private permissions for each.
8 J, Y' h$ r) uvar count = resultItem.getItemCount();
* [+ \% \0 M' f0 j1 ifor (i=0; i<count; ++i) {
" ~- k" W; j0 T. a var item = resultItem.getItemByIndex(i);
$ v# q* S6 _" M, `/ P // Start with a blank permission ) M6 Q. [6 |0 B& j/ w( C7 k
var permItem = item.setPrivatePermission(""); + k* o5 Q7 G ^# |6 D
// To copy from the current permission: permItem = item.setPrivatePermission();
, h+ ^ {' o$ `/ K" B( W6 E // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
" I" }5 N4 t3 P$ U( \$ | ( T7 I7 c1 n7 P( I
permItem.setProperty("name", permItem.getID()); \$ J. s4 W/ W. y" I
permItem.setIdentityAccess("Component Engineering", "get", true);
* i0 D; ^. y2 j; P A permItem.setIdentityAccess("CM", "get", true);
' j' _- t) ^* h$ N! c, J permItem.setIdentityAccess("CM", "update", true);
, @3 i5 o" n" |0 r, i4 @0 `, Q ' D9 |1 e2 V4 m# B! w1 T
// Grant access to the current user's alias identity ( }: q' Y; X7 F% Y9 U W
var aliasId = innovator.getUserAliases().split(',')[0]; . ?; K6 n% ]) W& p2 ]3 A/ V* v/ L
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); 9 w j/ O E4 ?
permItem.setIdentityAccess(aliasName, "get", true); # p4 O; C2 ^) C2 Z+ r
( }. B$ N! f6 L) B. k2 ]
item.setAction("edit");
4 d, t9 T" d9 N5 I resultItem = item.apply();
; z. f) N$ I/ {8 y if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } " U# ]/ H6 m% w2 c9 y
} " P! G: v' y# b9 R: E! x' B
" o* F* @* y* U' A F
|
|