Showing posts with label AgilePoint. Show all posts
Showing posts with label AgilePoint. Show all posts

Tuesday, August 23, 2016

Calling AgilePoint web services with PowerShell

AgilePoint has 2 main APIs that are really handy - Workflow.asmx and Admin.asmx. You could also access it via REST.
Today I'm going to show an example of how you could batch reassign tasks to users by making use of the workflow web service.

The services could be found here.
  • Workflow API - http://[qualified machine name]:[port]/[AgilePoint virtual directory]/workflow.asmx?WSDL
  • Administration API - http://[qualified machine name]:[port]/[AgilePoint virtual directory]/admin.asmx?WSDL

With PowerShell here is a very straightforward example of a classic web service that accepts simple data types.
Using a CSV file that contains user account mapping from DOMAIN1\user to NEWDOMAIN\user, first declare the variables you need. Here is a sample CSV

oldlogin,newlogin
DOMAIN1\user1,NEWDOMAIN\user1new
DOMAIN1\user2,NEWDOMAIN\user2new

 #****************************************************  
 # Variables  
 #****************************************************  
 $username = "DOMAIN\admin"  
 $password = "Password"  
 $wsWorkflowUrl = "http://agilepointserver:8000/AgilePointServer/Workflow.asmx?WSDL"  
 $wsAdminUrl = "http://agilepointserver:8000/AgilePointServer/Admin.asmx?WSDL"  
 $csvFile = "Users.csv"  


Then, create the credentials object and connect to the webservice. PowerShell has a built-in WebServiceProxy class which is really handy.

 #****************************************************  
 # Credentials and proxy to connect to web service  
 #****************************************************  
 $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))  
 $workflowProxy = New-WebServiceProxy -Uri $wsWorkflowUrl -Credential $cred  
 $adminProxy = New-WebServiceProxy -Uri $wsAdminUrl -Credential $cred  

In order to consume the service, here is a function to search for tasks assigned to a user, list all tasks, and reassign it to the new (migrated) user. It makes use of GetWorkListByUserID and ReassignWorkItem services.

 Function Reassign-AgilePointTasks ($originalUser, $migratedUser)   
 {  
   $response = $workflowProxy.GetWorkListByUserID($originalUser, "Assigned;Overdue")  
   ForEach ($item in $response) {  
     # Reassigns each task to the migrated user account in AgilePoint.  
     Write-Host "Reassigning task $($item.Name) $($item.WorkItemID)" -foregroundcolor "Yellow"  
     $reassign = $workflowProxy.ReassignWorkItem($item.WorkItemID, $migratedUser)  
     $textLogFileOK = "Reassignment to $($reassign.UserID) complete. $($reassign.Error)"  
        Add-Content -path $LogFileOK -value $textLogFileOK  
     Write-Host "Reassignment to $($reassign.UserID) complete. $($reassign.Error)" -backgroundcolor "Green"  
   }    
 }  

Finally, put all the pieces together by looping through the csv file, and reassigning the tasks user by user:

 #****************************************************  
 # Start Bulk AgilePoint migration  
 #****************************************************  
 Import-Csv $csvFile | ForEach-Object{  
         $originalUser = $_.oldlogin  
         $migratedUser = $_.newlogin  
         Reassign-AgilePointTasks -originalUser $originalUser -migratedUser $migratedUser  
         Write-Host "Migrated User " + $originalUser + " to " + $migratedUser  
}   

And we're done!

Sunday, February 1, 2015

AgilePoint InfoPath C# snippet - Retrieve repeating row data

Sometimes we would need to manipulate data from an InfoPath repeating field, use this data in our AgilePoint workflows. We would need to add custom code for this by using the Advanced Extensions - Managed Code stencil.

Sample of InfoPath schema:



I have a repeating row called Item with 3 fields or nodes.

My example would be to invoke a subprocess for each row of that data.
In order to access the data, I would need the System.Xml and System.Xml.XPath references in my code. I will make use of the XPathNavigator and XPathIterator functions to get data.

Sunday, May 4, 2014

AgilePoint: Clean up participant list

In a AgilePoint workflow template, you might have created some activities and assigned some participants to them, just to decide that you don't need them at a later stage.

To keep the template clean, always use the Custom Process Properties to manage and delete them.

You can find the Custom Process Properties under the Miscellaneous section of the AgilePoint tab in your Visio.

Highlight the line you do not need and click the Remove button.

And you're done.

Monday, April 28, 2014

AgilePoint: Suspect Infinite Loop in process

In AgilePoint we had a couple of processes that need to repeatedly check a certain condition and only continue once true.

Once our workflow was running in production environment, I noticed this error came about quite frequently.

Suspect infinite loop in process xxxx: 
Dear AgilePoint System Administrator, Process instance 'xxxxxx' has been suspended because maximum session was exceeded on Activity 'Wait for 1 hours'. Process Template = 'yyyyyyyy', Version = '1.31' You may check if it is infinite loop.

Friday, March 14, 2014

AgilePoint Infopath integration: XML content as parameter

If you ever need to pass the entire XML document/body of an InfoPath as a parameter in AgilePoint, use this:
$//
Just like any other attributes that you reference ($AttrName)

For example, when you are making use of a web service that accepts an XML document as a parameter.

When you are using managed C# code, you can do this instead:

Tuesday, March 4, 2014

AgilePoint (AgilePart) - Managed C# Code: How to get AdminService

In your lifetime of AgilePoint development you will commonly come across situations where you need to access system data such as process template information, delegations that are active and so on.
2 common services provided OOTB are the Workflow services object and AdminService services object.

You have probably come across code samples that shows you how to get the admin service in a standalone environment.
Now I am showing you a much easier method that can be integrated into your process template.

Wednesday, February 26, 2014

AgilePoint C# API: Updating a custom attribute

There are a couple of ways you could employ to update a custom process attribute in AgilePoint. If you have the premier license, it's available as a stencil under Premier Extension. This is pretty handy when you have simple, straightforward values.

However, when you need to manipulate data or perform complex data calculations prior to the update, you can make use of the Managed C# code stencil instead. It can be found under Advanced Extensions.
With just a simple line, you're on your way:
api.SetCustomAttr(pi.WorkObjectID, "YourAttributeName", "TheValue");

Retrieving?
string x = (string)api.GetCustomAttr(pi.WorkObjectID, "YourAttributeName");      

Sunday, January 5, 2014

AgilePoint InfoPath 2010 integration: Submit & Close button not showing on web browser forms

Situation: I had a web-browser enabled InfoPath 2010 form hosted in SharePoint that I wanted to apply AgilePoint workflows to. To my endless frustration, the "Submit and Close" button normally associated with InfoPath approvals simply would not appear, no matter how I tried.

According to AgilePoint documentation, I am supposed to perform several steps such as removing code from InfoPath (Form Options - Programming), closing the InfoPath form, opening AgilePoint envision, creating a dummy InfoPath template and that would fix the issue. Obviously this is not working for InfoPath 2010 web-browser enabled forms!

Sunday, November 17, 2013

AgilePoint step by step: Bulk Process Migration

Real World Scenario: AgilePoint BPMS 5.0 SP4

So you have a couple of workflows already deployed to Production, and have hundreds of active processes running. One day your Business User comes to you and says: "Can we do X and Y and then also R,S,T, U while you're making the changes.."

Fine, you think. OK, a couple of days later you deployed the new workflow, and THEN your Business User says: "Look there's a system bug and the issue is not fixed. How come my process is still doing A and B? I thought you have already made changes???"

err.... didn't I already mention that the change would only apply on NEW processes? LOL.

Now here's what you need to do to remedy it!

Related Posts Plugin for WordPress, Blogger...