BMoberg - Monday, March 3, 2014 9:56 AM:
In Aras 10
I have an Item with a simple lifecycle (Active - Closed)
I want to create a button on the form, where I can promote the lifecycle to Closed by a click.
I have working methods for saving and unlocking the item, but I would like to have it promoted also.
I've created a metod (Javascript, client side) with the following two lines:
var myItem = document.thisItem;
myItem.promote("Closed", "Promoted by Aras");
I've then added this method to a button with "onClick" (Field Event)
BUT nothing happens When i click on the button?
Does anyone have a working method for this?
Thanks/Benny
Harsha - Thursday, March 13, 2014 3:11 AM:
First, you have to add the Lifecycle transition's 'Role' as permission identity in the code. To do this you should use a server method(As I know). So, call a server method which has code to promote the item from the button click.
An example:
BLOCKED SCRIPT
var thisItem = document.thisItem;
var id = thisItem.getID();
var body = "<id_>"+id+"</id_>";
var result = top.aras.applyMethod("ServerMethodName",body);
return result;
C#:
Innovator inn = this.getInnovator();
string id = this.getProperty("id_");
Item item_ = inn.getItemById("ItemTypeName",id);
Aras.Server.Security.Identity roleIden = Aras.Server.Security.Identity.GetByName("Owner"); //--Your Transition's Role here
bool SetPermission = Aras.Server.Security.Permissions.GrantIdentity(roleIden);
item_.setAction("promoteItem");
item_.setProperty("state", "Closed");
Item res = item_.apply();
if (res.isError()) {
return inn.newError("Error promoting Item: " + res.getErrorDetail());
}
if (SetPermission = 1) {
Aras.Server.Security.Permissions.RevokeIdentity(roleIden);
}
return this;
Don't forget to Unlock the item before you click button to promote, or handle the same in the code.
Thank you/Harsha
BMoberg - Thursday, March 13, 2014 4:13 AM:
Thanks for the reply Harsha!
One step closer... I've tried this but it stops on line number 14, "Error number CS0031, Constant value '1' cannot be converted to a 'bool'."
Line 14: if (SetPermission = 1) {
Sorry, I am new at this. Any suggestions?
Harsha - Thursday, March 13, 2014 4:29 AM:
Sorry, my mistake. C# thing, replace 1 with true: if (SetPermission == true) {
BMoberg - Thursday, March 13, 2014 5:51 AM:
Perfekt!
Big thanks Harsha!