ergr - Monday, August 11, 2014 7:18 AM:
Hi,
I have the following C# code, which is called from an Action(Item Action for Itemtype1) to create an Item(PRC is my Itemtype) and also to edit the created Item.
In the Itemtype I added 'Can Add' as 'Administrators' and in the Permissions:
Only Administrator Can Update. If I logged in as an Administrator the code is Adding/Updating item. But if I logged in as an User the code is not working.
I think this is because of the permissions given, because I can see the error messages complaining about permissions.
C#:
Innovator inn = this.getInnovator();
string prc_id = this.getProperty("prc_id"); //-- ItemType1's properties
if(prc_is==null || prc_id == "")
{
Item newPRC = inn.newItem("PRC","add");
newPRC.setProperty("Chk_id",this.getID());
newPRC.setProperty("file_prc",this.getProperty("file_",""));
newPRC = newPRC.apply();
this.setProperty("prc_id",newPRC.getID());
}
else
{
Item editPRC = inn.getItemById("PRC", prc_id);
editPRC.setAction("edit");
editPRC.setProperty("file_prc",this.getProperty("file_",""));
editPRC = editPRC.apply();
}
return this;
How to handle the permissions in the code?
I don't want any user to add the item from selecting 'new' / edit the item. Items should be added/edited only from code.
Thank you,
ErgR
zahar - Monday, August 11, 2014 7:23 AM:
what you need to do is to put around your code following:
before your code:
Aras.Server.Security.Identity plmIdentity;
bool PermissionWasSet;
//asign ARAS PLM to current user
plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM"); //set whatever Identity you use as admin
PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);
ergr - Tuesday, August 12, 2014 1:32 AM:
Thank you so much Zahar, it worked.
