PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

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

x
Technique  4 J$ N  \" H' a8 x- R
Use the Item Class Extended Method set to set a new private Permission for an Item. $ L) s3 O) m+ k0 c5 _3 r7 u1 L
JavaScript  
- O9 w; A: z2 F- ]// Set up the Part query
$ g/ R+ q2 e/ g( K. evar innovator = this.newInnovator(); ! G& p" O& Z  W# }( S3 a2 V
var qryItem = this.newItem("Part", "get");
# ^) E- T& ?/ I4 I/ {- F8 b, ZqryItem.setAttribute("select", "id,permission_id"); . U$ `- q, B& g0 q$ U9 U
qryItem.setProperty("item_number", "123-456%", "like"); * [3 d# p3 P/ n6 p. d1 D0 v

  @7 t  ?8 r0 T// Run the query and check for errors
3 X# Q! S4 R  ^; r# v" Y+ s6 K0 zvar resultItem = qryItem.apply(); * K. c/ f( l: x/ Z9 P1 \
if (resultItem.isError()) { ' h& f  [1 i+ W" A) ~/ ]2 F2 ^; l
top.aras.AlertError(resultItem.getErrorDetail()); & s6 d- N  M! b; Y$ I4 ?& c9 z
return;
8 r# L/ R9 L. T% E0 o2 r# Y* H; Y} 8 L: |! |4 ~/ f5 b6 Z
7 r3 I& _( \; v4 g. M+ H% I! b, m
// Iterate over the Items returned and add the private permissions for each.
1 w/ O$ m. D. U5 `2 Z9 [; Avar count = resultItem.getItemCount(); 0 z# Y3 Z/ J% R& r6 I* y% H
for (i=0; i<count; ++i) {
, c$ R% z( s, p var item = resultItem.getItemByIndex(i);
/ U  U) C$ i' L/ l) ]1 J // Start with a blank permission
) l8 v+ O' h( J* [/ p% d9 b+ O6 \ var permItem = item.setPrivatePermission("");
5 h! x$ j( d/ I2 o. C // To copy from the current permission: permItem = item.setPrivatePermission();
" v% i3 {2 m& Z5 {1 Y // To copy from a named permission: permItem = item.setPrivatePermission("New Part"); * X; n3 l3 r) h
% A9 U6 d5 L8 v/ ]! ?( p! I- j* `
permItem.setProperty("name", permItem.getID()); ) d* W/ c  l" m+ a# Y
permItem.setIdentityAccess("Component Engineering", "get", true);
2 M4 M3 \4 ?! H; y- a permItem.setIdentityAccess("CM", "get", true); - I/ }& {1 s7 y1 P% f) F# o  P
permItem.setIdentityAccess("CM", "update", true);
5 c4 I/ j9 M- ?5 v" J( e 5 L  I3 x2 L# S
// Grant access to the current user's alias identity
  e; t8 A' f  Y: m. K7 j0 O* ~) j- X var aliasId = innovator.getUserAliases().split(',')[0]; 8 n" l7 z# c) \5 y/ u
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name"); ' [9 |! O5 }- |0 Z! ?! v8 |# d$ `
permItem.setIdentityAccess(aliasName, "get", true);
- L' d! U' f& v0 S# U, Z- Q0 [
1 x% |, z4 |8 u! ~( ]7 ]' S0 r item.setAction("edit");
2 ^( c$ q3 g! h* o, |( ^! V resultItem = item.apply();
6 l: y3 S+ d  ] if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
8 R+ O) c. S+ b# U}
0 T3 o5 \" W1 v: o1 [/ b6 C
3 o9 s) l# h. s2 V0 M2 c; Q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了