【Aras 二次开发代码】为对象Item设置私有权限
TechniqueUse the Item Class Extended Method set to set a new private Permission for an Item.
JavaScript
// Set up the Part query
var innovator = this.newInnovator();
var qryItem = this.newItem("Part", "get");
qryItem.setAttribute("select", "id,permission_id");
qryItem.setProperty("item_number", "123-456%", "like");
// Run the query and check for errors
var resultItem = qryItem.apply();
if (resultItem.isError()) {
top.aras.AlertError(resultItem.getErrorDetail());
return;
}
// Iterate over the Items returned and add the private permissions for each.
var count = resultItem.getItemCount();
for (i=0; i<count; ++i) {
var item = resultItem.getItemByIndex(i);
// Start with a blank permission
var permItem = item.setPrivatePermission("");
// To copy from the current permission: permItem = item.setPrivatePermission();
// To copy from a named permission: permItem = item.setPrivatePermission("New Part");
permItem.setProperty("name", permItem.getID());
permItem.setIdentityAccess("Component Engineering", "get", true);
permItem.setIdentityAccess("CM", "get", true);
permItem.setIdentityAccess("CM", "update", true);
// Grant access to the current user's alias identity
var aliasId = innovator.getUserAliases().split(',');
var aliasName = innovator.getItemById("Identity",aliasId).getProperty("name");
permItem.setIdentityAccess(aliasName, "get", true);
item.setAction("edit");
resultItem = item.apply();
if (resultItem.isError()) { top.aras.AlertError(resultItem.getErrorDetail()); }
}
页:
[1]