PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2018-8-1 13:56:44

请使用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
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了