|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
4 c: w$ T+ j A' I% k# Y$ iUse the Item Class Extended Method set to set a new private Permission for an Item. 3 l' d" q* {% P
JavaScript & t* l" X9 F: s7 E8 B% o4 O8 [
// Set up the Part query 3 l5 n& Q% ^6 ^' o5 o4 v5 P
var innovator = this.newInnovator();
3 s+ M& @$ V% x( z4 D, }5 Y Kvar qryItem = this.newItem("Part", "get");
$ B! S% \! R7 J& s5 V& _$ l" XqryItem.setAttribute("select", "id,permission_id"); 5 l4 Y$ J O8 p5 w+ { L2 j4 y
qryItem.setProperty("item_number", "123-456%", "like");
- Q0 W6 z# C) h7 O1 m% r
0 v' ^: q' N* u+ f; g1 r// Run the query and check for errors $ U! r" Y; @. E6 E0 m
var resultItem = qryItem.apply(); 2 }6 j S; \. f' @. V$ w7 i" Y. l: E
if (resultItem.isError()) { 5 _0 A. c1 |" [9 a( f
top.aras.AlertError(resultItem.getErrorDetail()); p' L7 f* T. e4 w. l
return;
+ R- V( h& A0 o7 S2 y} 1 A1 K2 e$ x3 p" L& C
- d; @# r. c, M4 e- P- ~// Iterate over the Items returned and add the private permissions for each.
: d4 z; j. r; ?var count = resultItem.getItemCount();
3 m: P! R& a5 C6 h3 xfor (i=0; i<count; ++i) { $ A: t$ x* v$ l# { f, I7 S( ^8 p8 r
var item = resultItem.getItemByIndex(i);
9 d, c" F* {- f6 o0 E // Start with a blank permission
t% R& B" v! w- { var permItem = item.setPrivatePermission("");
" L+ I1 R: J2 G( v' Q // To copy from the current permission: permItem = item.setPrivatePermission(); 1 T8 u$ a, b$ M
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
. v" I- I5 C/ c
8 _$ d# ~ V6 n0 U permItem.setProperty("name", permItem.getID());
% P( Z6 b& L$ Z8 C/ ?+ u, k permItem.setIdentityAccess("Component Engineering", "get", true); + }9 R4 g: n, D& {4 h! m) d
permItem.setIdentityAccess("CM", "get", true);
0 W# z* C1 A( g7 t# Y9 z permItem.setIdentityAccess("CM", "update", true); / S/ T5 }4 y+ E" [' I
: e) `* g2 D) E' e // Grant access to the current user's alias identity * [) Y& j, ~, Q+ _
var aliasId = innovator.getUserAliases().split(',')[0]; ; p! J# F# |8 p* J9 T& M
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ! Y' w' l7 C5 m% m0 s4 F
permItem.setIdentityAccess(aliasName, "get", true); - v- o* G6 P, \( ]
5 n! }# |7 Z9 s8 G- Q. V item.setAction("edit"); ; d* O' D4 D" c6 \. D# O/ H
resultItem = item.apply();
; `3 M& e6 e3 U6 o$ _# P if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
. u6 G" M8 O2 b) N}
. ? z8 B+ R, I9 J) Q0 I% C% X9 U7 M$ H9 Z. ^1 n
|
|