Showing posts with label K2-Workflows. Show all posts
Showing posts with label K2-Workflows. Show all posts

Monday, August 29, 2011

K2.Net 2003: Request failed with HTTP status 401: Unauthorized


As we know there are many steps need top be followed to setup the K2.Net 2003. Each step it has its own importance.If we miss any step in configuration we get a specific error for that. Recently we have tried to move the SharePoint List to a new site collection and updated this URL in string table and submit the workflow. So while creating a new list item the workflow got into error state and the error reads like below (below image). We have given Full Permissions on the site and the list, but none of these things worked. Finally after doing this and that I have found that the service account is not listed under site collection administrators. So I have added the account there and tried to repair and it worked so fine. Thought this will help others. So shared here!
So just you know, the steps required for adding the permissions under site collection:
1. Go to Site Actions
2. Select Modify Site Settings
3. Go to site collection Administration
4. Select Top level Settings (if you see this link under that)
5. Next page, under Users and Permissions section click Site collection administrator
6. The next page will show you the Editor showing people picker (check names image and browse)
7. Add the service account into that.


Hope it helps!!!

Wednesday, March 2, 2011

Find WorkListItems with Worklist Criteria Filter in K2 Blackpearl

While working for an utility to redirect the tasks with some custom functionality I had to search for an option to bring the WorklistItems (tasks) based on some criteria (like Folio or Title) using LIKE operator with K2 API classes WorkflowCriteria and WorkflowCriteriaFilter, but it didn’t work. Googled with some keywords and found few articles, but I could not see any simple solution from them. So did some trials on search criteria on my own finally I could figure out that if we use percentile (%) symbols with LIKE operator it works perfectly. I didn't expect this as the APIs itself should take care (as per my understanding) of this when we use LIKE operator in Criteria classes. Anyway, it is working fine for me. I thought my findings may help some folks so posted that piece of code here.


 //Create a connection string with Integrated mode
    SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder();
        connectionString.Authenticate = true;
        connectionString.Host = "ServerName";
        connectionString.Integrated = true;
        connectionString.IsPrimaryLogin = true;
        connectionString.Port = 5555;

        WorkflowManagementServer workflowServer = new WorkflowManagementServer();
        try
        {
            //Create a connection
            workflowServer.CreateConnection();
            workflowServer.Connection.Open(connectionString.ToString());

            WorklistCriteriaFilter filter = new WorklistCriteriaFilter();
            // Without % symbols it won't bring any data. It is important to add
   filter.AddRegularFilter(WorklistFields.Folio, Comparison.Like, "%srinitest%");
        
WorklistItems listItems = workflowServer.GetWorklistItems(filter);
            foreach (WorklistItem item in listItems)
            {
                //Add a row  to table to show it on form
   //AddRow(item.ProcInstID.ToString(),item.Folio,item.ActivityName,     item.EventName, item.Destination, item.ProcName);

            }
        }
        catch (Exception ex)
        {
            //Handle Exception here
        }
        finally
        {
         if (workflowServer != null && workflowServer.Connection != null)
            {
                //Dispose the connection saftely
                workflowServer.Connection.Dispose();
            }
        }

You can also find the code here Download

     Hope it helps!

Thursday, February 24, 2011

Updating DataField Values within a K2 Process Instance without Admin Access

We had an issue while updating the datafield values without executing the action in the application form. If we use ProcessInstance Update method, it was obvious that we need to provide the admin rights for all the users which is not an ideal solution. So we found in the K2 Blackpearl Arcticles that we can update the Data Fields with an Action seperately created for that with in the workflow defintion. The information is described below.

 

Updating Values within a K2 Process Instance

KB Number:KB000307

Introduction

When updating values (i.e. a data field) of a process instance without completing the process in pre-0807 releases of K2 blackpearl it was possible to use the [WorkListItem].[ProcessInstance].Update() method. In K2 blackpearl 0807 the [WorkListItem].[ProcessInstance].Update() method now requires a user with process Admin rights.

The recommended way to update values of a process instance without completing it is to use the Actions["UpdateWorkItem"].Execute() method. The Action must be configured to support the updating of the work item in order to use the Execute method in the API.

Configure the Action in K2 Designer for Visual Studio

The Add Action dialogue screen contains a radio button option that enables the Action to be updated without the Worklist item being completed: Click here  to see the screen shot that shows the configuration for Save with action name UpdateWorkItem.
This radio button must be selected in order to programatically update the value within a process instance.

Update the Work Item Using the K2 API

The recommended method uses an "update" action, as opposed to firing the ProcessInstance.Update() method, so will work without Admin permissions:

SourceCode.Workflow.Client.WorklistItem wi;
wi.ProcessInstance.DataFields["TestDF"].Value = "2";
wi.Actions["UpdateWorkItem"].Execute();

Remember that the Action must be configured using the This action will update the work item option during the design of the process, as demonstrated in the K2 Designer for Visual Studio section above.

The following sample will now only work if it is called by a user with Admin permissions on the process:

SourceCode.Workflow.Client.WorklistItem wi;
wi.ProcessInstance.DataFields["TestDF"].Value = "2";
wi.ProcessInstance.Update();

 

 

 

Friday, January 7, 2011

K2 Blakpearl Installation Trouble Shooting

After installing all the components you may see lot of errors showing in configuration wizard. Few of the follwing steps will help you to solve the issues (esp.  see if there are any Kerbero's issues).

1. To see System Stored userids, run the following line in Run window (delete if you find any, with caution)
 To do: rundll32.exe keymgr.dll,KRShowKeyMgr

2. SPNs check
 To do: setspn -l domain/service_account 
ex: setspn -l gs/service_admin 

3. Duplicate SPNs check

To do:  1. setspn -x 
                It lists out all the SPNs in the environment in DOS console

             2. setspn -x > D:\test\log.txt 
               It writes all the SPNs list to a file specified in the directory path as shown above.

4. DelegConfig download (try in google)
To do:  Search in google with the word DelegConfig you will get the links to download this app.
              Here is one link:
              http://www.iis.net/community/default.aspx?tabid=34&g=6&i=1887

             Download it and createe a virtual directory under IIS. Open the site and that takes you     through  all  the config settings, and shows the status of Kerberoes setup configuration.

5. Service Account Delegation Setup
To do: K2 Service account needs to be delegated with SharePoint App pool (identity) account in Active Directory. (This solves the 401 unauthorization Kerberos issue for Blakpearl– SharePoint communication, like through the smart objects).

You may not have all these issues but if you find that there is something going wrong with your installation, you can find this information helpful to trouble shoot.

K2.net Studio has encountered a problem and needs to close

When we were trying to open the K2 studio we got the follwing error.
"K2.net Studio has encountered a problem and needs to close. We are sorry for the inconevenience."
Error screen shot below:
Solution:
1. Login with your Id (if it is in server)
2. Go to RegEdit and Navigate to the path
3. HKEY_CURRENT_USER\Software\SourceCode
4. Delete the K2.net Studio Folder

Now open the K2 Studio, this may fix your issue. It worked fine for me.

Thursday, July 8, 2010

K2.Net 2003 - Authentication with server failed

Suddenly in one of our test environments, K2.Net 2003 Service Manager was throwing an error popup with “Authentication with server failed” message. This environment was not setup recently and it was working very fine earlier. But all of a sudden it started throwing this error and stopped working.


We did check all the server configuration and services nothing seemed to be wrong. But finally we found that in K2 and K2 log databases we have _procUsers, _ServerUsers and _ProcRights tables. These tables were having some user ids for same proc set id for more than once. So that was causing the issue. We took help of K2 guys and removed all these duplicates. It again started working fine.

Not sure why this error says authentication failed instead of showing something related to these duplicate user records message. But you can find the correct message when you start the K2services through console in the K2 Server (logon with Service account) or Server event logs.

Hope it helps



Thursday, May 6, 2010

K2.Net 2003 workflow - Invalid text value exception issue

Issue:System.Exception: Invalid text value A text field contains invalid data. Please check the value and try again. at K2Code10097.Main(ServerEventContext& K2)

Description:This error is occuring when the K2.Net 2003 workflow was trying to insert the data into SharePoint list column, which is a single line text datatype.

Solution:Initially, when I looked at this error in K2Service Manager, I was thinking that the problem is with the datafields those are carrying data to update into SharePoint. I have one utility where I can query the complete DataFields data of a process Instance, and edit and update. Its kind of massaging the data and pushing into system. So using this I tried to update all the special characters with some encoded values for DataFields and tried to repair the error. But it didn't work at all. After a lot of trials, I started comparing the data size of the DataFields those are involved in updating the SharePoint columns with tye size of Sharepoint columns. Finally I found a column which has datatype as singleline text (allows 255 chars), but it was being tried to update more data than it allows. Then I changed the data type to multiline text and repaired the error. This time the error gone and process moved forward succesfully.

So the problem is with the data of a DataField that has more chars than the sharepoint column that was being tried to allows.
Hope this helps....

Tuesday, May 4, 2010

Issue with K2 workflow: Could not load file or assembly

Recently, we have released a k2.net 2003 workflow into production that uses a C#.Net dll to hold database and some custom functionality. Initially all the workflows were using the same dll locally, but with the new workflow release we have signed the assembly and kept in GAC. With this change the new workflows working fine but the other existing workflows going to error state as they were developed to use the dll locally and it was not signed dll. Finally created a ticket with K2 to get ther support and they solved the problem with one hot fix.
Error Description:System.IO.FileLoadException: Could not load file or assembly 'K2Classes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'K2Classes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' at K2Code11748..ctor()

Resolution: The assembly, K2Classes.dll, for the existing processes was referenced locally in K2 Studio in which case it gets serialized to the K2 database when the process is exported, and then gets extracted to the \work\[procid] directory at runtime. The assembly was recently signed and referenced from the GAC for a new process, then installed in the GAC and the \K2.net 2003\bin directory on the server. The new process is working but the older processes are trying to use the new version of the dll and failing.
"If the assembly is copied to the \k2.net 2003\bin directory, all process instances, regardless of how the custom assembly is referenced in the Studio project (GAC or locally), will always use the assembly in the \K2.net 2003\bin directory."
Stopped the K2 service, removed the K2Classes.dll from the \k2.net 2003\bin directory, restarted the service and able to repair the existing instances, but then the instances of the new process started failin with the following error even though the dll is still in the GAC: 5015 Unhandled Exception in Code Item LineRule - Default1 : 4116 Error Compiling Process : 4116 Error Compiling Process : Compile Error: Imports Line 0: Metadata file 'K2Classes.dll' could not be found
The new process was not picking up the assembly from the GAC due to a known bug that is fixed in hotfix 2. After installing the hotfix, we were able to repair the new process instances successfully and confirmed that the process instances from the older are working fine.

Really thanks to K2 Ssupport to solve this issue on production.

Thursday, April 8, 2010

Update DataFields for K2 Blackpearl workflows

Hi,
Here I am going to discuss about the K2 .net 2003 and BlackPearl (BP) workflows DataFields those help in repairing the workflows those got into error state. As we all know DataFields in workflows plays a big role in carrying the transactional data that are useful for decision making in workflow activities, especially in deciding line rules (Off course in BP we have actions to decide lines rules).

When I started working BP workflows few months back, I observed that fixing BP error workflows is not that easy as compared to K2.net 2003. Usually in K2.Net 2003 we add some condition related to process Instance ID (ProcInstID) and repair the error. Even thought BP has provided that ability to do it from Visual studio, it is not that easy to repair them as BP workflows uses XOML internally and every time we repair this error it deploys a new version workflow ( we can see this in version window of workflows in workspace). I didn't like this as this is risky thing to do this. Finally I found some way using APIs and updated the DataFields and repaired the workflows by just updating the DataFields. It was so easy.
Here is the code:
protected Connection GetBPConnection()
{

SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
//connectionString.Authenticate = true;
connectionString.Host = "localhost";
connectionString.Integrated = true;
connectionString.IsPrimaryLogin = true;
connectionString.Port = 5252;

Connection connection = new Connection();
connection.Open(txtServerName.Text, connectionString.ConnectionString);
return connection;
}

protected void UpdateBPFields(string strFieldName, string strOldValue, string strNewValue)
{
SourceCode.Workflow.Client.ProcessInstance objBPProcessInst;
using (Connection connection = GetBPConnection())
{
//Create process instance
objBPProcessInst = connection.OpenProcessInstance(Convert.ToInt32(txtProcInstID.Text));

foreach (DataField dField in objBPProcessInst.DataFields)
{
//Check which FataField you want to update
if (dField.Name == strFieldName)
{
dField.Value = strNewValue;
}

}
// Call Update Method to update the DatField value
objBPProcessInst.Update();

}
}

For this utility you need to know the ProcInstID workflow which is gone into error state. This is easy to get them, in error profiles each workflow error shows the ProcInstID in the gird, as below.


Even we can do the same thing for K2.Net 2003 workflows.

This process not only helps for Error Workflows but for Active workflows. Sometimes, we might need to update some DataFields to change some rules after workflow started. The same process can be applied for K2.Net 2003, but the name spaces will be different (K2ROM.dll). For active workflow you can get the process Instance ID from workspaces (when you keep the mouse on workflow “ViewFlow” button you can see the ProcInstID in status bar, for K2 and BP workflows).

For K2 Error workflows you can see the ProcInstID directly in Error profile like below.


Hope it helps!

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...