Aras Innovator Platform

Add a Named Permission

You want to add a new named Permission Item.

Technique

Use the Item Class Extended Method set to add a new Named Permission Item.

JavaScript

var innovator = new Innovator();
var permItem = innovator.newItem(“Permission”,"add”);
permItem.setProperty(“name”, “AK Part Permissions”);
setIdentityAccess(permItem, “All Employees”, “get”, true);
setIdentityAccess(permItem, “CM”, “get”, true);
setIdentityAccess(permItem, “CM”, “update”, true);
setIdentityAccess(permItem, “CM”, “delete”, true);
resultItem = permItem.apply();
if (resultItem.isError()) {
top.aras.AlertError(resultItem.getErrorDetail());
return;
}

function setIdentityAccess(item, identityName, permType, accessState)
{
var identity = item.newItem();
identity.setType(“Identity”);
identity.setAction(“get”);
identity.setProperty(“name”, identityName);
var access = item.newItem(“Access”,"add”);
access.setProperty(“can_"+permType, (accessState ? “1" : “0"));
access.setRelatedItem(identity);
item.addRelationship(access);
}