|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique / S& E& e8 Q, Y1 p
Use the Item Class Extended Method set to set a new private Permission for an Item.
1 p. t- Z4 Q7 f1 Y \. fJavaScript
% J' \! A" L& ^8 A4 d, b// Set up the Part query
1 `; M# ~4 N0 U0 Avar innovator = this.newInnovator();
& f5 i( H& Q# J# w- Y" xvar qryItem = this.newItem("Part", "get"); , ~: Z$ L% }9 w9 S" n
qryItem.setAttribute("select", "id,permission_id");
7 Y1 U% i; @2 Z& o, f+ i, rqryItem.setProperty("item_number", "123-456%", "like");
+ u# u) x0 w0 d: `& E 1 w: o" L( N4 n' E/ H0 L/ ^, V
// Run the query and check for errors
5 q* w& x# Z# X3 bvar resultItem = qryItem.apply(); 1 V+ m2 J* U- a
if (resultItem.isError()) { + D3 i: f! w1 P# Z
top.aras.AlertError(resultItem.getErrorDetail()); 0 `& e# O: T. G3 v
return;
0 s* u4 Y) b- ~# i3 j) z) W}
: }( F9 O. \5 w7 D) j1 ^) z8 E ' O$ A* t/ V7 a" E0 L |; {/ \
// Iterate over the Items returned and add the private permissions for each.
8 B5 b% s! W+ S* F) g) ?* ivar count = resultItem.getItemCount(); 4 } B4 d5 Y" A" p- u$ g6 T
for (i=0; i<count; ++i) { 1 q4 D$ i/ E+ `2 F8 B6 o/ e( O; i
var item = resultItem.getItemByIndex(i);
6 _7 c& V0 J- H) t* e$ B6 X! l5 V // Start with a blank permission d2 _, m" r$ a
var permItem = item.setPrivatePermission(""); . K% c: P' n/ R% _
// To copy from the current permission: permItem = item.setPrivatePermission();
9 u- V. e/ Y" S' O; K2 n1 A. ^7 | // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
* X3 `( P) L0 q. `4 U. C
- J# w- S- [ H! i permItem.setProperty("name", permItem.getID()); w/ z4 a0 A% N7 A! Z
permItem.setIdentityAccess("Component Engineering", "get", true); ) t* i' m' ~( I3 a( [/ X4 `
permItem.setIdentityAccess("CM", "get", true); 2 f2 a9 r( q) X1 @: z
permItem.setIdentityAccess("CM", "update", true); " @& R0 \) }3 ~7 ~
7 s' n6 j( |! N" U7 E
// Grant access to the current user's alias identity 2 k) F+ G8 X' y/ ]
var aliasId = innovator.getUserAliases().split(',')[0]; 3 Y, u+ k) j4 S" S
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); + d1 S+ ^% ]5 Y/ ^! s. L; J0 z
permItem.setIdentityAccess(aliasName, "get", true);
6 g, N8 e T9 b2 @
7 L A- I# o$ X+ o' U8 ~9 N2 h item.setAction("edit"); 2 U" q5 Y; g) |, |+ r9 R V
resultItem = item.apply(); , l$ H7 B, _# E& h1 R7 M( K* a. P
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
j9 D [, e. X}
& k. L) @# Q$ @4 T8 S0 U$ _8 K8 E
* a3 O" I+ J% ]2 R" c- R0 F5 t# j |
|