daniele - Thursday, January 20, 2011 8:37 AM:
Hi
It's possible to vote for a workflow activity using c#? I need to pass through all workflow's activity without user intervention using a c# application.
Thanks.
Brian - Friday, January 21, 2011 7:20 AM:
Hi Daniele,
Workflows allow you to have "automatic" activties that don't need users to vote for them.
On the right hand side of the centre pane of the Workflow Designer there are some checkboxes. Check the "Automatic" checkbox and the activity will just complete without a user.
The rule that you need to follow with Automatic activities is that they need to have a "Default" path out of them.
This is easier than using a c# program to vote for the activites.
If you really need to "vote" using a c# program I'm sure it can be done I just haven't tried it.
Hope this helps,
Cheers,
Brian.
daniele - Monday, January 24, 2011 7:35 AM:
Hi
thank for your answer. I can't use automatic workflow because the user must choose the path. What I've done is create an AML string like the one that the aras' vote window create, then I submit it with applyAML() method. Do you think it works in the right way?
Bye
Daniele.
Ronan - Monday, January 24, 2011 9:10 AM:
Hi Daniele,
See the "Workflow Automation Examples" community project, it contains good wf automation samples.
RobMcAveney - Friday, January 28, 2011 11:03 AM:
To answer the original question, yes it is possible to submit a workflow vote programmatically. As Brian and Ronan said, it is usually not necessary as you can build the automation into the workflow itself. However, if you really need to do it, the code would look something like this:
// Build the voting request
StringBuilder voteXml = new StringBuilder("");
voteXml.Append("<Item type="Activity" action="EvaluateActivity">");
voteXml.Append(" <Activity>{0}</Activity>");
voteXml.Append(" <ActivityAssignment>{1}</ActivityAssignment>");
voteXml.Append(" <Paths>");
voteXml.Append(" <Path id="{2}">{3}</Path>");
voteXml.Append(" </Paths>");
voteXml.Append(" <DelegateTo>0</DelegateTo>");
voteXml.Append(" <Tasks />");
voteXml.Append(" <Variables />");
voteXml.Append(" <Authentication mode="" />");
voteXml.Append(" <Comments>{4}</Comments>");
voteXml.Append(" <Complete>1</Complete>");
voteXml.Append("</Item>");
// Submit the vote
Item res = inn.newItem();
res.loadAML(String.Format(voteXml.ToString(),actId,assignId,pathId,vote,comment));
res = res.apply();
return res;
sherenegladysj - Tuesday, April 12, 2011 7:43 AM:
Hello Rob,
Thanks for your quick reply.
I would be adding the "Workflow Process Path" dynamically with source id and related id. SO I won't be having the path id. What can I do???
scottmahr - Tuesday, April 19, 2011 4:56 PM:
Very quick question, where do I find "EvaluateActivity"? I can't find it in methods, or anywhere on the server.
Thanks,
Scott
sherenegladysj - Tuesday, May 10, 2011 8:02 AM:
Hello
in the above method return res will update the vote through programatically. say for an activity if there are three assignees then how would I return the result to vote for all the three assignements. I'm running this method on scheduler. How to achieve this?
Thanks
RobMcAveney - Tuesday, April 12, 2011 7:50 AM:
Can you describe in general what you are trying to do? I can think of a way to make it work without having a path id, but it is not an elegant solution. If you can describe why you need to vote programmatically I may be able to suggest an alternate approach.
sherenegladysj - Thursday, May 12, 2011 7:40 AM:
Hello Rob,
Is there a way to vote programmatically for two or more assignees using the below code???
// Build the voting request
StringBuilder voteXml = new StringBuilder("");
voteXml.Append("<Item type="Activity" action="EvaluateActivity">");
voteXml.Append(" <Activity>{0}</Activity>");
voteXml.Append(" <ActivityAssignment>{1}</ActivityAssignment>");
voteXml.Append(" <Paths>");
voteXml.Append(" <Path id="{2}">{3}</Path>");
voteXml.Append(" </Paths>");
voteXml.Append(" <DelegateTo>0</DelegateTo>");
voteXml.Append(" <Tasks />");
voteXml.Append(" <Variables />");
voteXml.Append(" <Authentication mode="" />");
voteXml.Append(" <Comments>{4}</Comments>");
voteXml.Append(" <Complete>1</Complete>");
voteXml.Append("</Item>");
// Submit the vote
Item res = inn.newItem();
res.loadAML(String.Format(voteXml.ToString(),actId,assignId,pathId,vote,comment));
res = res.apply();
return res;
The return res statement ends the program execution for one assignee and it is not running for other assignees. Without return statement am not able to Vote it. Can u please help in this scenario?
Thanks.
sherenegladysj - Wednesday, April 13, 2011 5:05 AM:
My Scenario is like this:
1. I have a workflow with five activities with start date and ENd date. If an activity crosses the end date, it should go to "Expired" state. From there if user wants to extend he may "Extend" the end date else he may close it.
2. So from each activity "Expire" path won't be there, if it crosses the End date then I'm creating dynamically Expire path from the current activity to "Expired" activity. So I may not be having Path id in this case.
Please suggest if there is any alternate solution
RobMcAveney - Thursday, May 12, 2011 8:42 AM:
You have to submit one EvaluateActivity request with a different ActivityAssignment value for each vote. The easiest way would be to use multiple apply() calls:
// Submit the votes
Item res = inn.newItem();
res.loadAML(String.Format(voteXml.ToString(),actId,assignId,pathId,vote,comment));
res = res.apply();
if (res.isError()) return res;
res.loadAML(String.Format(voteXml.ToString(),actId,assignId2,pathId,vote,comment));
res = res.apply();
return res;
RobMcAveney - Wednesday, April 13, 2011 7:57 AM:
This scenario is similar to a proposed feature that is under consideration for a future version. I can't say for sure when it will be included, but we have recognized this as a good use case to cover. I think you are on the right track to implement this in advance of the standard feature, and I encourage you to share the solution with the community when you are done.
If you are dynamically creating the Expire path then you definitely have access to its id. If you are creating the path in the same method as the vote then the response from the request that adds the path contains the id. Your code to add the path should look something like this:
Dim newPath As Item = Me.newItem("Workflow Process Path","add")
newPath.setProperty("source_id",actId)
newPath.setProperty("related_id",expireActId)
newPath.setProperty("name","Expire")
newPath = newPath.apply()
If (newPath.isError()) Then Return newPath
' The following line retrieves the path id
Dim pathId As String = newPath.getID()
If you are creating the path in a different method then you can always query for the id before you vote, like this:
Dim expirePath As Item = Me.newItem("Workflow Process Path","get")
expirePath.setProperty("source_id",actId)
expirePath.setProperty("name","Expire")
expirePath = expirePath.apply()
If (expirePath.isError()) Then Return expirePath
' The following line retrieves the path id
Dim pathId As String = expirePath.getID()
sherenegladysj - Friday, May 13, 2011 5:30 AM:
Hello Rob,
Thanks for your reply. For "innovator Admin" as an Assignee, I am able to vote using the above method without any error. For other assignees "other than admin user" I am getting the following error while executing the method; "An internal error has occured.Workflow: EvaluateActivity: User is not from allowed identity" Though I have given all permissions whichever added to Admin user; still I'm getting this error. What could be the reason?
Thanks
RobMcAveney - Friday, May 13, 2011 9:34 AM:
You need to use GrantIdentity to temporarily give the current user membership in each assigned identity. For example, if the assignment is for Change Specialist I then you would need code like this:
Aras.Server.Security.Identity assignedIdent = Aras.Server.Security.Identity.GetByName("Change Specialist I");
bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(assignedIdent);
res = res.apply();
if (res.isError()) return res;
if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(assignedIdent);
You'll need to loop through the assignments and do this for each one.
sagar_makhesana - Thursday, April 17, 2014 8:15 AM:
Hello Rob,
I tried the code as Server side method [ VB ] on the activity i want to vote it programmatically.
//Build the voting request
StringBuilder voteXml = New StringBuilder("");
voteXml.Append("<Item type="Activity" action="EvaluateActivity">");
voteXml.Append(" <Activity>{0}</Activity>");
voteXml.Append(" <ActivityAssignment>{1}</ActivityAssignment>");
voteXml.Append(" <Paths>");
voteXml.Append(" <Path id="{2}">{3}</Path>");
voteXml.Append(" </Paths>");
voteXml.Append(" <DelegateTo>0</DelegateTo>");
voteXml.Append(" <Tasks />");
voteXml.Append(" <Variables />");
voteXml.Append(" <Authentication mode="" />");
voteXml.Append(" <Comments>{4}</Comments>");
voteXml.Append(" <Complete>1</Complete>");
voteXml.Append("</Item>");
// Submit the vote
Item res = inn.newItem();
res.loadAML(String.Format(voteXml.ToString(),actId,assignId,pathId,vote,comment));
res = res.apply();
Return res;
When i tried to check syntax it gives error message like
Could not load file or assembly 'file:
and gives the random name of DLL file every time like
tgbo69rv.dll
5r43kjuv.dll
Can you help me to resolve it?
Thanks in advance :-)