|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Technique
& w) n4 b% p+ i* TUse the Item Class Extended Method set to set a new private Permission for an Item.
8 o8 Z; D4 S) t6 tJavaScript
0 n! s1 C9 {0 e7 e// Set up the Part query 2 d& P1 F. A+ W$ d! e
var innovator = this.newInnovator();
; ?: J) m& r# Y+ h. D2 k, {var qryItem = this.newItem("Part", "get"); 3 ?- e# {9 n- J
qryItem.setAttribute("select", "id,permission_id");
, V J& |9 A' j0 KqryItem.setProperty("item_number", "123-456%", "like");
7 P2 N9 d5 O0 k- I 3 A$ l* O* M; d! n! ]& p0 U
// Run the query and check for errors " @2 Z6 T, ]* D, F# U
var resultItem = qryItem.apply();
/ C$ R1 s/ o% I; R' H6 D' Eif (resultItem.isError()) { % J/ z3 M* M$ x0 {2 `
top.aras.AlertError(resultItem.getErrorDetail());
7 K4 V v/ f: l1 J3 ?; G return; / D. @3 n8 h) e
} ' a% A/ ?/ p7 e; |/ d8 I
( s) ?+ v# Y' o8 a: d
// Iterate over the Items returned and add the private permissions for each. 2 F8 T" }0 Q, j k7 [
var count = resultItem.getItemCount(); * B% D5 [+ Z1 L5 O1 Y
for (i=0; i<count; ++i) {
! I# V3 n/ ^5 M1 |; h var item = resultItem.getItemByIndex(i);
0 b$ x- a- W8 m: ~ // Start with a blank permission
4 z' I* p/ y4 o9 } var permItem = item.setPrivatePermission(""); - [0 {3 f- |, Q: H2 i) n
// To copy from the current permission: permItem = item.setPrivatePermission();
; u/ X* q# d j, i& L8 j0 m. k // To copy from a named permission: permItem = item.setPrivatePermission("New Part");
3 e6 {& M6 u# S2 s/ Y, d: m. n* s
9 f% j% x, I. @5 ]& b0 G8 X+ e permItem.setProperty("name", permItem.getID()); # A$ n+ h& i" j5 ]
permItem.setIdentityAccess("Component Engineering", "get", true);
. @; s& }' Q8 D, }" c' G& w* k permItem.setIdentityAccess("CM", "get", true);
' o+ H3 H `! a- ]# a1 q2 Q permItem.setIdentityAccess("CM", "update", true); J) ]% w4 l3 |" G/ `
/ c/ S8 U4 O& D
// Grant access to the current user's alias identity
$ z% B# [; F- b1 _8 W0 S; g var aliasId = innovator.getUserAliases().split(',')[0]; 9 S) H b; f3 V
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
V q* r) X- f5 h permItem.setIdentityAccess(aliasName, "get", true);
) \6 u! Y8 h- H a% {4 J0 V) O' Q
# `$ ^7 x# z$ v/ J" i, H f item.setAction("edit"); * O/ _ k: U7 C G' Z7 z
resultItem = item.apply(); 7 N+ H6 Y( b) w8 B, z) _/ C$ {
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 2 F' s" w) m [
} 3 G0 @3 B j6 _" w2 X
7 v' r" ?/ [. y8 g! |/ ~ |
|