|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
4 v1 M& _ Q) R& N/ V2 K( GUse the Item Class Extended Method set to set a new private Permission for an Item. 4 d |# o" [" L* m- V& d: o
JavaScript
1 H9 R; N' A5 y7 z6 Z( F// Set up the Part query & N! h$ O% m: }# d, ~' ]
var innovator = this.newInnovator(); ) a/ {: `4 c6 y; ^+ _3 W* @4 {
var qryItem = this.newItem("Part", "get"); 5 k# I. H8 v' ?! F
qryItem.setAttribute("select", "id,permission_id");
' P x- U# S" i0 K7 m6 {7 bqryItem.setProperty("item_number", "123-456%", "like"); ( F# @2 g4 B4 h
|7 U% A! Z+ I/ t
// Run the query and check for errors # Y% o* R- Y# J; L' V5 x5 V+ f% U
var resultItem = qryItem.apply();
- u! M# h2 Q/ [4 ?. }( |if (resultItem.isError()) { $ S( B* e0 v) G! Q% h- g0 H, U2 H
top.aras.AlertError(resultItem.getErrorDetail());
9 B* S$ x# e+ Q# i7 z2 W return; : |5 _# W& Q8 S1 z2 l9 i
} : x6 m5 d( V. A4 H; \5 o; q$ m
$ ~4 T/ C! V/ {. o% _, C8 l! m" Q// Iterate over the Items returned and add the private permissions for each. 0 V/ ^9 G" _# M+ N
var count = resultItem.getItemCount();
$ f6 j, y- V5 q' O) efor (i=0; i<count; ++i) { + e% [$ F$ I s6 T! m
var item = resultItem.getItemByIndex(i); 9 v% U( d+ Q) g- M& g, P! ?
// Start with a blank permission ; Y1 G6 ]6 c/ p7 L% P( V% N; c
var permItem = item.setPrivatePermission(""); ! Q' @1 a& N# l$ {
// To copy from the current permission: permItem = item.setPrivatePermission(); ' h4 r+ Y* N, @0 w6 z! @
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
8 x1 |% q) E- h* [* Y8 c5 h- Q
! [* m& Z) e. F% N1 J permItem.setProperty("name", permItem.getID()); $ a* ?" k5 P6 |3 B! A5 O t
permItem.setIdentityAccess("Component Engineering", "get", true);
1 C+ Z* B2 n3 i, T permItem.setIdentityAccess("CM", "get", true);
$ G" C. W% n5 p0 f/ E5 Z permItem.setIdentityAccess("CM", "update", true); 6 }8 _* L- Q0 ]! v
1 o% K% B; E/ D% j- [: t# S8 C // Grant access to the current user's alias identity
' i( t- T6 V; k J var aliasId = innovator.getUserAliases().split(',')[0]; / R' g6 C" }" J1 y& f4 [7 r: l
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); : P7 s8 C! k+ \' X
permItem.setIdentityAccess(aliasName, "get", true); ! Z# R6 y3 i, H8 a2 R
/ T ^6 J. y) u, [ item.setAction("edit"); ( a7 I* m8 o! \- H' J: |
resultItem = item.apply();
o% t, G* K5 [. [& B if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
: `- e$ }# f1 d# v: N$ F' i} 8 ^ n. B% v5 S- h) B* m
5 E+ U' L* _( g+ j5 i |
|