PLM之家PLMHome-工业软件与AI结合践行者

【Aras 二次开发代码】为对象Item设置私有权限

[复制链接]

2018-8-1 13:56:44 2121 0

admin 发表于 2018-8-1 13:56:44 |阅读模式

admin 楼主

2018-8-1 13:56:44

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
Technique  * q/ t, n! I& N$ r, o3 u, j
Use the Item Class Extended Method set to set a new private Permission for an Item. & Y# M; S! |0 |" Z8 w+ M
JavaScript  6 Q. o: t- c/ A0 L6 ^# c/ C
// Set up the Part query
' F$ A: D' ]. m* g7 wvar innovator = this.newInnovator();
- U9 ]5 ?# I4 x/ }3 Z; r  }' H: Jvar qryItem = this.newItem("Part", "get"); $ }+ [% T4 \  R; }: D6 h
qryItem.setAttribute("select", "id,permission_id");
* M1 j- @$ ]4 l' t) z& h* S! I! Z; D4 HqryItem.setProperty("item_number", "123-456%", "like"); 4 ^9 i2 h- O. k; ~
: F6 H7 a' P0 c. ]8 s
// Run the query and check for errors
8 }, I: ]+ T6 L4 [$ R$ A6 {var resultItem = qryItem.apply(); % ~) ]/ O6 T: r3 M8 Y1 N# D
if (resultItem.isError()) { 8 S; ^' d+ `& {9 V$ y% p1 O4 S
top.aras.AlertError(resultItem.getErrorDetail());
4 G& z# Y: S# @: a return;
* g+ T" d+ I5 o5 h1 B  l}
" s, R+ X4 P7 D: s : o% U( _% I, p) I+ h8 x
// Iterate over the Items returned and add the private permissions for each. 3 {) {0 U# j' t: _% ~6 n
var count = resultItem.getItemCount();
1 a7 p2 a# c7 u% p+ b' lfor (i=0; i<count; ++i) { ! i5 t" f/ A$ Y: f5 S' `
var item = resultItem.getItemByIndex(i);
! _2 r/ S% i/ p6 K$ P% ~ // Start with a blank permission
8 K+ Z" a; n8 g7 n7 i. G var permItem = item.setPrivatePermission(""); 5 y$ t% I: ]: h  O
// To copy from the current permission: permItem = item.setPrivatePermission();
/ M" [* Z/ Z" N9 h // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); ; c6 k5 U1 ^& E9 j6 D( l
: f& z' M6 O, ~" n/ W2 |' I
permItem.setProperty("name", permItem.getID());
+ W4 b1 K/ v$ E( m permItem.setIdentityAccess("Component Engineering", "get", true);
  |9 l7 w, v. ^! g% h; \* X& p permItem.setIdentityAccess("CM", "get", true); ! c/ N. @4 ?! x
permItem.setIdentityAccess("CM", "update", true);
& Y/ u& P# V" E) N" E0 |
$ \+ S' \9 z7 d3 I$ H( |# i" F // Grant access to the current user's alias identity
: X5 r7 _5 A2 W4 v# R var aliasId = innovator.getUserAliases().split(',')[0];
* F6 U% \" P; x3 m var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ; X6 ^5 V* ^$ j
permItem.setIdentityAccess(aliasName, "get", true);
! G: r" Z0 e( J% |4 |; B 7 H# J# S7 k7 f8 ?* t! A& T+ n
item.setAction("edit"); " d# F! k& v$ z
resultItem = item.apply(); . e# G% Z! }+ P6 F! w8 v$ T- I
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } ' g5 o" f7 J/ S1 i
} 9 c& C  A* K3 ]4 ]1 t' _
- o, U% s* G1 N1 D$ I% b& j
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了