|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique ) D/ F& r( D! G6 i4 E- ^! l
Use the Item Class Extended Method set to set a new private Permission for an Item. ! g6 I( l" P# P5 L/ x
JavaScript ) z2 C- F, \0 T: L6 N# \
// Set up the Part query - `0 s& D2 H' C( ^7 F0 x+ t8 o+ G8 L
var innovator = this.newInnovator(); : k% B4 t! A* m$ }. V; p- [: C S
var qryItem = this.newItem("Part", "get");
+ ?, x9 C# s; ^2 P! |/ }1 pqryItem.setAttribute("select", "id,permission_id"); $ W! T: X, ^* P7 w" i
qryItem.setProperty("item_number", "123-456%", "like");
% B2 F* H6 A( d% Y! x# P4 I0 L : I$ N$ K+ \+ s3 N R
// Run the query and check for errors 8 U0 W2 H+ F7 I' w6 ^0 J1 N4 D
var resultItem = qryItem.apply();
: O" }% [, j+ f2 i/ q) Vif (resultItem.isError()) {
% c9 C" [- K* i1 A9 e! S2 p# g9 x top.aras.AlertError(resultItem.getErrorDetail());
" o" E5 x4 ?9 ^& x return;
2 N: L8 j, o5 f. M& H( b} # F* B4 |# n8 G1 r. a+ j: E
3 e1 b K! J+ `9 s5 N3 E: z# O// Iterate over the Items returned and add the private permissions for each.
2 M5 I) f3 C0 Y2 cvar count = resultItem.getItemCount(); & j+ n2 R% l! H1 X! p$ v& I
for (i=0; i<count; ++i) { , t, U5 P9 a2 n9 ?6 b J; ^/ _6 i
var item = resultItem.getItemByIndex(i); 0 f7 i$ j- q u; V7 z
// Start with a blank permission
/ q3 u- o' [0 ` var permItem = item.setPrivatePermission("");
/ c* c. O7 E- ~9 ^. d; U // To copy from the current permission: permItem = item.setPrivatePermission();
! ~1 M5 ~' B8 s: B$ @% {6 f // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); * y' J- b& T# {- o
0 \& c* B4 H) X" M4 Y
permItem.setProperty("name", permItem.getID()); ) E8 Y- W8 h Z* W/ [" q
permItem.setIdentityAccess("Component Engineering", "get", true); / }: I- ~$ Y. k: O
permItem.setIdentityAccess("CM", "get", true); f- z9 T4 |, `; {
permItem.setIdentityAccess("CM", "update", true);
3 l' @* t, P! ^3 k! x6 ~$ d6 V
% q8 g7 x8 B! @" Y1 r# G // Grant access to the current user's alias identity
: b" @0 j/ z; t& K/ V' m! ^ var aliasId = innovator.getUserAliases().split(',')[0];
& e- c& U3 O" q2 D0 W var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
" A* j: H3 z" y! ^2 V# K permItem.setIdentityAccess(aliasName, "get", true);
5 A4 M" ]! h. J# b" A
! B* u' @! x- s1 I% v% N item.setAction("edit");
: c8 H3 E$ m% Q resultItem = item.apply(); 3 R( g/ e! U, g! f7 L( p
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
% }7 u6 b7 L: a2 q6 D9 j} 6 M1 w, L4 i. {
4 X( \/ r! v( A8 Q |
|