K2 integrated with custom aspx form

  • 6 September 2012
  • 8 replies
  • 3 views

Badge +4

Need to know the best procedure to develop a K2 workflow with custom aspx pages. Any sample solution will be much more appreciated.


8 replies

Badge +9

Create a asp.net webappl and host onto IIS. Create a k2 process in which use a client event and provide ur task page URL in the wizard. Assign an SN with URL. When a task is created for a destination it creates a sn number. Depending on the SN number, complete the Approve/ Reject actions. Below code to complete the actions using K2 API.


public static bool CompleteTaskListItem(string SerialNumber, string action)


        {


            bool isTaskCompleted = false;


 


            //Create a K2 connection string to Workflow server using standard defaults


            SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionBuilder = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


            connectionBuilder.Authenticate = true;


            connectionBuilder.Host = ConfigurationManager.AppSettings["K2HostServer"].ToString(); //"localhost";


            connectionBuilder.IsPrimaryLogin = true;


            connectionBuilder.SecurityLabelName = ConfigurationManager.AppSettings["K2SecurityLabel"]; //"K2";


            connectionBuilder.Port = uint.Parse(ConfigurationManager.AppSettings["K2WorkFlowPort"]); //5252;


            connectionBuilder.Integrated = true;


 


            try


            {


                using (SourceCode.Workflow.Client.Connection connectionToWorkflow = new SourceCode.Workflow.Client.Connection())


                {


                    connectionToWorkflow.Open(ConfigurationManager.AppSettings["K2HostServer"].ToString(), connectionBuilder.ToString());


                    connectionToWorkflow.ImpersonateUser(SPContext.Current.Web.CurrentUser.LoginName);


 


                    SourceCode.Workflow.Client.WorklistItem workListItem = connectionToWorkflow.OpenWorklistItem(SerialNumber);


 


                    workListItem.Actions[action].Execute();


                    connectionToWorkflow.RevertUser();


                    isTaskCompleted = true;


                }


            }


            catch (Exception ex)


            {


                ex.ToString();


                isTaskCompleted = false;


                throw new Exception(ex.Message);


                //throw new Exception("Unable to connect K2 Server. Please contact Sysytem Administrator.");


            }


            return isTaskCompleted;


        }


 

Badge +4

Thanks for the fast response. I have one doubt in this. At a particular step (say for example initiator has submitted a request and the task item is created for approver) approver and requestor should have different view of the same task form(eg. approve.aspx). For approver there should be some remarks section with approve/reject button and for initiator there should be cancel button. How to achieve this? Whether K2 provides some out of box functionality or we have to write asp.net code for this.


Another question is how to populate the workflow task form with the actions a user can take at a particular point in the process based on his rights.

Badge +9

For first question, there is no k2 out of box funcionality to achieve this. You should write ur custom coding depends on the initiator or approver view maintaining in querystring or database.


For second question, show actions in a dropdown or as buttons depending on approver view. WHen a 3rd person tried to complete the actions, k2 will check the rights and accordingly completes the task at k2 side.

Badge +4

We have below requirment,


We have One SP list(Order Request). First User will create the request(list item) by filling up custom aspx page. so while list item creation he will fill up data and upon submitting workflow will start and K2 work list item will be created . We will assign custom aspx page (for Delivery Manager) to the task during task creation. 


After this, The Delivery Manager should get an email and In turn he should Go and Edit the K2 task list item to fill data related to him. So on edition and of this work list item The Technical Analyst should get an email and he in turn will edit the list to fill the subsequent user and details.


SharePoint Workflow Integration process  will be the right choice ?? Or else any better way to proceed?? (application related data wil be stored in SP List and workflow related data will be stored in k2 DB). Since we are new to k2 please elaborate the solution.


Regards


Nanda

Badge +9

You can use Sharepoint workflow integration process wizard or u can go for K2 API to create process instance as u said u r using custom aspx page. However u r using k2 api to complete the task actions from custom form.

Badge +4

Please correct me if I am wrong. As per my understanding we have to go with K2 API as we have to use custom aspx page(Sharepoint Application Pages) throughout the approval process. Sharepoint workflow integration wizard does not provide any option for associating custom aspx pages as you have suggested to do through default client event.


(Does Sharepoint workflow integration wizard provide any option for associating custom aspx page url as u hv suggested in case of default client event? If yes please let me know the process)


With K2 API option we can not map aspx form fields with K2 process fields during design. Everything has to be handled through code. So the dynamism of K2 will be less utilized.


Regards,


Nanda

Badge +9

I am not sure whether SP workflow event wizard provide custom aspx page as task, i suggest SP hosted aspx page tobe used in default client event would be the better option.

Badge +4

Hi Srikanth thanks for the suggestion. I am facing an issue with using a SharePoint group in K2Studio with BlackPearl


Grabbing the SharePoint group using the Context Browser and setting this as destination user for an activity but task is not getting generated for the users present in that group.


can you please suggest what could be the problem.


Regards,


Nanda

Reply