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

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

[复制链接]

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

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

admin 楼主

2018-8-1 13:56:44

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

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

x
Technique  
4 I, |, a* O$ M8 G/ e/ ?Use the Item Class Extended Method set to set a new private Permission for an Item. ! i' Q. C, q! ~
JavaScript  - X5 m) a& e8 ]9 ]# r& g7 v9 [) g& ?
// Set up the Part query
' Y5 u  x' D0 svar innovator = this.newInnovator();
3 K" S3 d: D: j( E: \; i5 x% Y8 ^3 ^- jvar qryItem = this.newItem("Part", "get");
4 G  f* W+ M# o7 V9 T9 ?: J+ RqryItem.setAttribute("select", "id,permission_id");
! _) p- K1 @9 t  H+ \- lqryItem.setProperty("item_number", "123-456%", "like"); , D3 y0 e9 }" x$ A/ p% z4 A
/ N/ q- n' {9 C* r
// Run the query and check for errors
0 }! ~" x/ t! i9 S* qvar resultItem = qryItem.apply(); ! G0 C* L. }% E# i0 c7 p" p
if (resultItem.isError()) { % U# j# I, w4 O9 g  b2 O
top.aras.AlertError(resultItem.getErrorDetail());
9 l4 {3 E; Z# ~- e' S return; 6 s8 p/ C. H0 g
}
+ X$ {0 A' Z  b6 R$ o' `! j9 j- i ' F! g! q/ n& ?: P: x+ w$ T/ \# ?
// Iterate over the Items returned and add the private permissions for each.
# k$ I* C% O) |' N; {var count = resultItem.getItemCount();
5 V! f, T+ z  b: ]! I  M: r) Zfor (i=0; i<count; ++i) {
8 |" p/ J' T3 V! A/ M4 d; D' Y var item = resultItem.getItemByIndex(i);
( v# p+ z; _6 a- d+ [ // Start with a blank permission
% z1 O# [" j9 L# |8 _' w2 p var permItem = item.setPrivatePermission("");
: ^; h9 m) ?' v1 V' S4 P( h // To copy from the current permission: permItem = item.setPrivatePermission(); 1 A" W0 b  u) q% A; d7 ]0 v1 Z% O
// To copy from a named permission: permItem = item.setPrivatePermission("New Part"); 6 Y5 I8 e6 c9 v! n' t6 o
5 q- N% ]4 \+ x1 t6 Q1 W$ I8 ]1 A7 z
permItem.setProperty("name", permItem.getID()); / i( ?9 Q; |# k/ _2 o5 {
permItem.setIdentityAccess("Component Engineering", "get", true); 3 t; |. r( U! g! M
permItem.setIdentityAccess("CM", "get", true);
' L, `* Q; A% l6 s permItem.setIdentityAccess("CM", "update", true); 2 z/ K, j- G" }5 |

) O$ M* J8 P  E% f/ _; ` // Grant access to the current user's alias identity
( v% k* ?+ o+ V- m1 P var aliasId = innovator.getUserAliases().split(',')[0]; : M$ K  C1 v9 p
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
( O$ R9 E3 {  y0 V permItem.setIdentityAccess(aliasName, "get", true);
" w3 Y; t2 `- E# h1 U& J, I+ \ 5 T% I2 i8 A7 w8 k: K
item.setAction("edit");
6 @, e- R& P1 E! x3 L resultItem = item.apply(); % ~0 h* B; S6 M% O1 K) f( F
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); } 5 h* s; g+ P9 J1 d* X4 p, g
}
; d' L9 u7 P/ B: `6 \! q% g/ k; Y4 l1 A; ]- o2 P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了