Welcome to EMC Consulting Blogs Sign in | Join | Help

Kiran Bellala's Blog

  • InfoPath Digital signature tips and tricks

    Disable form submission without digital signature

    You may have a requirement that an InfoPath form cannot be submitted without a signature on it. This can be achieved very easily in InfoPath with the need for custom code.

    1.       Create a section and enable digital signature on that section.

    2.       Add a submit button to the form.

    3.       Add a rule of formatting type on the submit button.

    a.       In the rule you will see the name of the signature section. Set up a rule such that when the section is not signed, disable the button.

    Form Validation

    Programmatically clear digital signatures

                    Another common requirement that you may see in the context of digital signatures and workflows is that when an approver rejects an InfoPath form and sends it back to submitter for rework, all the digital signatures have to be erased from the form. This can be done in code.

                    A digital signature on InfoPath form is nothing but an xml node with encrypted data in it. Removing digital signature can be achieved by deleting the signature node. You can get a reference to the signatures on the form with SignedDataBlockCollection. A signature block can contain one or more signatures.

    So to delete signatures:

    if (this.Signed)

                    {

                        SignedDataBlockCollection blocks = this.SignedDataBlocks;

                        foreach (SignedDataBlock block in blocks)

                        {

                            SignatureCollection signs = block.Signatures;

                            if (signs.Count > 0)

                            {

                                foreach (Signature sign in signs)

                                {

                                    XPathNavigator nav = sign.SignatureBlockXmlNode;

                                    nav.DeleteSelf();

                                    this.CurrentView.ForceUpdate();

                                    MessageBox.Show("Signature removed");   

                                }

                            }

                        }

                    }

  • Digital signatures in InfoPath forms and K2

    Validation in pharmaceutical industry:

    21 CFR Part 11 is a set of rules and guidelines developed FDA (Food and drug administration) for pharmaceutical industry. If a pharmaceutical company wants to maintain electronic records instead of paper based records, then the systems, databases and network has to comply with the rules in CFR part 11.  During the course of designing and developing a new drug, a pharmaceuticals company has to submit several kinds of documents to FDA. Once a compound has been discovered, it has to be tested. All the data collected during the drug trials has to comply with Part 11. After a software system has been designed and developed, it has to be guaranteed that the system complies with the guidelines described in Part 11 before it can be put to use in the pharma company. This process is called as “Validation”. There are companies that provide software validation services for pharmaceutical industry.

    One of the requirements of 21 CFR Part 11 validations is that all records have to be digitally signed and the data cannot be changed after record has been signed. If the data has changed, then there should be a clear trail of who changed when and what was changed.

    For my client, I developed workflows to automate Clinical trial processes using K2 blackpearl and InfoPath 2007. This is how the workflow goes:

    1.       Submitter fills the form and signs the form with his/her digital signature.

    2.       Submitter submits the form.

    3.       K2 blackpearl process (workflow) starts.

    4.       Workflow engine creates a task and assigns it to the approver.

    a.       When approver clicks on the task, it opens the InfoPath form already filled by the submitter.

    b.      Same InfoPath form will be used by submitter and approver, since approver may have to make changes to the fields filled in by Submitter.

     InfoPath supports digital signatures. In InfoPath 2007 you can allow users to sign an InfoPath form before they submit the form. Digital signatures confirm that the contents of the form were not altered after it has been signed. When the form is signed, InfoPath locks the controls on the form and makes them read-only.  When you hover over these locked controls, you will see a small Digital Signature icon indicating that the control is read-only. In InfoPath there are 2 ways to use digital signatures:

    1.       Sign entire form

    2.       Sign parts of the form.

    digital signaturs InfoPath

     

    Since most of the data in my form is regulatory data, my first inclination was to allow signing entire form with digital signature. Quickly I realized that it is not possible in K2 workflows. My workflow starts by submitter submitting the form. This means, I had to use InfoPath Integration Process wizard so that the form becomes initiation form. 

    During the InfoPath integration process wizard, K2 adds several things to the form one of which is a section with name _k2.  This section is added by K2 to let workflow engine control the form during the flight of the workflow. K2 will change values in this section during various stages of the workflow. 

    k2 specific fields InfoPath

    If you lock entire form with signature, K2 would still make changes the fields in _k2 section. When the values in these fields change, the signature becomes invalid. One important thing to note here is that, if a form is signed, it cannot be changed from UI but the xml within the form can be changed programmatically.  In such an event, the signature becomes invalid because some data has changed. Users would see invalid signature error message on the form and it defeats the whole purpose digital signatures.

                    So the next option form me is to enable digital signatures for only a section of the form. I moved all my InfoPath fields to a new group and left _k2 group as a separate group. Then I enabled digital signatures to this new group. However, there are still some more fields to exclude from digital signatures.

                    I am using the same form as both initiation form and task form (in K2 terminology it is client event). This is achieved by creating views on the form. For client events, K2 adds a field called as “Task Actions fields”.  When an action is taken in the client event, say approve or deny, the action is captured on the task action field. When the form is submitted to the workflow engine, K2 looks at the action field and determines whether the form is approved or denied. These task actions fields also should not be signed by digital signature. These action fields will be changed during course of the workflow. So there is no point in signing these action fields. If we sign these action fields with signature, then their value would change, which means the digital signature becomes invalid.

                    Hence a good practice while starting the design of your form is to create a section called as “Signature Data” or something similar. Exclude _k2 section from this section. Exclude all your task action fields. If there are any other fields that will change during course of your workflow (ex: approver comments), exclude them as well.

  • Differences between K2 blackpearl and SharePoint workflows

    If you have spent several years developing custom SharePoint workflows and then started working with K2 blackpearl, you would notice some big differences in developing workflows using these two technologies.

    One key thing to remember here is that k2 blackpearl is an enterprise workflow engine. SharePoint is not a pre-requisite for K2 blackpearl. K2 can be deployed in environments without SharePoint. However, K2 provides first class support for SharePoint. That being said let’s look at some key differences between these two technologies.

    #1: Worklist items Vs SharePoint Tasks

    We all know that in SharePoint world Workflow task is the corner stone of any SharePoint workflow. When we need to get end user’s input, say an approval, we create a task and assign the task to the user. In K2, this concept is achieved by using Client events. A client event creates a Worklist item for the user. This worklist item is similar to SharePoint task. But unlike SharePoint task, a worklist item is created within K2’s database.

    In a normal K2 process, K2 does not create tasks in any SharePoint tasks lists. However, we can design a workflow that is centered on SharePoint tasks. But we will miss on some of the nice features of K2. They are Escalations, reporting, working hours etc.  K2 has a powerful reporting engine. In fact SSRS is a pre-requisite for K2 installation. Since the K2 worklist items are created within K2 database you can create very complex reports on how much time a person is taking to finish a task. If the workflow is mission critical one, then you can derive several business metrics from the worklist item execution patterns.

    However there are some drawbacks when you compare a worklist item to a SharePoint task. In SharePoint, we can easily extend the metadata of the task. All you have to do is create new columns in the SharePoint task list. We cannot easily extend the metadata of the worklist item in K2.

    In regular workflows, you may not need custom properties on a worklist item. But consider this scenario:

    You designed a workflow to automate the invoice process for sales. A sales person is assigned 14 customers. Each customer is in a different region. Now you want a count of all the pending invoice approval tasks in say North East region. If you don’t have metadata on the worklist item, then it is not possible to build such reports.    

    As far as I know, the only property of worklist item available for customization is “Folio”. Rest of the properties/fields cannot be modified. K2 worklist item Folio is a text property which is like Title property of the SharePoint list item.  You can use this field to embed some metadata to the worklist item. For the above example, we can set Folio as Region_CustomerName_CurrentDate.

    K2 has a standard web part that displays the pending or open worklist items. While this web part is enough for most scenarios and does its main job – which is to display the pending tasks, this web part may not be suited for all your business scenarios and you may have to develop custom web part using K2 API.

    In my scenario, business wanted a count of all pending tasks grouped by region. I developed a custom web part that parses the folio field and displayed the counts.

    #2:  InfoPath form submission

    In a normal SharePoint workflow, a user fills an InfoPath form. Upon submission, using InfoPath form’s data connections, you would save InfoPath form to the form library. Workflow will be triggered because a new item is added to the library or modified. 

    In K2, after the end user fills in the form, the form has to be submitted to K2 workflow engine. Not to a form library. This is done by K2 web service. When you use InfoPath Process integration wizard, K2 adds a data connection to this web service. The job of this web service is to take the xml of the InfoPath and give to workflow engine.

    If you want to save the xml in a form library, what you can do is, in the workflow you can extract the InfoPath’s xml and then save that as a file using SharePoint Document or List item event. You don’t need to write any custom code to do that.

    #3: Use smartobjects where ever you can

    Normally in a SharePoint workflow, when you have to reference data from a line of business system, you would develop a web service and then call that web service in the workflow. In K2, this can be achieved using smartobjects. Smartobject technology is a very powerful integration technology. In simple terms, smartobjects surface out data from various data sources. The technology is similar to BDC/BCS but not same. With BDC/BCS, you have to create an external list to bring the data from external system into SharePoint’s context. Then you can reference this data in workflows. With smartobjects, you can use Smartobject events within workflow and then call any method on the smartobject directly within workflow.

    So, before you jump into Visual Studio to develop a custom web service, see how you can use smartobjects.  Using smartobjects will reduce the amount of custom code to maintain.

  • SharePoint specific features in K2 blackpearl

    K2 blackpearl provides excellent support for both MOSS 2007 and SharePoint 2010. In my previous posts, I mentioned that out of box K2 provides event wizards for various enterprise applications like Active directory, SharePoint, Dynamics CRM.  In this blog post I will describe K2’s SharePoint integration in detail.

    Starting a K2 workflow based on a SharePoint event

                    You can use SharePoint event process wizard to start a K2 workflow based on SharePoint event. Remember that process wizards deal with how a process can be started in K2 whereas event wizards are used within a workflow.

    Events available to start a K2 process are:

    List level events:

    ·         Field Added, Field Deleted, Field Updated

    Item level events:

    ·         Item Added , Item Deleted , Item Updated

    ·         Item Checked In, Item Checked-Out

    Some interesting events that we typically don’t see in normal SharePoint workflows are:

    ·         Item Attachment Added

    ·         Item Attachment Deleted

    ·         Item Unchecked-Out

    ·         Item File Moved – this event occurs when a file in the document library is moved to a different location

    ·         Item File Converted

     

    Apart from process wizards, K2 has several event wizards. These event wizards can be used within any workflow. Below are the event wizards available that can be used in any workflow:

    K2 Blackpearl events1

     

    SharePoint sites and workspaces wizard: Using this wizard, you can create a new SharePoint site, delete a site or update site properties.

    SharePoint Lists and Libraries wizard: Using this wizard you can create new lists and libraries.

    SharePoint Lists items wizard: Using this wizard, you can add, delete or update a list item in a list.

    SharePoint Documents wizard: Using this wizard, you can add, delete or update a document’s properties in a library.

    SharePoint Records Management wizard: Using this wizard, you can do several things in the context of records management:

    a) Add a new document to record center

    b) Add or remove holds on a record

    K2 blackpearl records management

    SharePoint Search Event Wizard: This is a very interesting concept. You can use this wizard to search for a keyword within a list or library or within a search scope. You can build a custom search query also and then search across lists. The search results are saved to a content field. Think of content field as a container for several list items. Once the content field is populated with results, you can copy/move/edit the items in the content field.

    SharePoint Publishing Wizard: As the name suggests, you can create, copy, move or check in publishing pages. But the cool thing here is that you can edit the content of a publishing page also within a content control.

    SharePoint user management wizard: using this wizard you can add users to a SharePoint group and manage permissions. You can also break permission inheritance or reset inheritance on a list or library.

                    As you can see, out of box K2 provides very deep integration with SharePoint. In SharePoint 2010, K2 provides integration with document sets as well. All the above functionality can be achieved in normal SharePoint workflows but it requires a lot of custom code. K2 makes these features available in K2 Studio thus enabling power users and business analysts to build complex workflows.

     

     

  • K2 blackpearl introduction for a SharePoint programmer -2

    In my previous blog post I touched upon some building blocks of K2 blackpearl. I will touch upon some more K2 blackpearl concepts.

    Client Events:

    A client event is similar to a task in SharePoint world. When we need the user’s input in a SharePoint workflow, we create a task and associate a task form to that task. In a similar fashion, when we need user’s input in K2 blackpearl workflow, we use a client event.

    A client event generates a “Worklist item”. This is similar to a Workflow task in SharePoint world. Worklist item represents a unit of work that needs to be performed by the workflow actor.

    K2 provides 3 types of client event wizards:

    InfoPath client event wizard:  

    This wizard allows you to specify an InfoPath form that acts as the user interface to the worklist item. End users will action his or her task using the InfoPath form.  Note that this wizard is similar to but not same as InfoPath Process Wizard. In the InfoPath process wizard, you would specify how to start the workflow when the form is submitted. But in the client event wizard, you specify how to take action on the task.

    Forms generation client event wizard:

    If you use this wizard as the client event, then K2 will generate a standard aspx page that acts as the UI for the worklist item. K2 generates code-behind file also for this aspx page. This aspx page can be customized and so is the code in the c# file.

    Default client event wizard:

    You can specify a custom form as the UI for the worklist item. The custom form can be a custom aspx page, a mobile web page or even an Exchange form. Of course you would be using K2 API and write custom code to send the user’s action to the worklist item.

    Lines and line rules:

    Lines in a K2 process dictate the process flow. Activities are connected using lines. Lines have rules called as Line Rules. These rules are nothing but logical expressions that evaluate to true or false. When the line rule is true, workflow execution takes that path.  

    Escalations:

    Task escalation is a very common requirement that we hear in workflow projects.  Escalations are not available out of the box in SharePoint workflows and you need to build them. K2 provides excellent support for escalations.  When a worklist item is not completed in certain amount of time, you can take a special action. This special action can be one of several things like: Send an email, Go to another activity, expire the activity.

    Working Hours:

    Another cool thing built into K2 blackpearl is the concept of working hours. Many workflows are time sensitive and certain actions need to be completed in fixed amount of time. But at the same time, if a user does not complete his or her task, escalation clock should not start in the middle of the night and send an email to his boss saying that the user did not complete his task.

    Working hours help in starting the escalations and notifications based on business and non-business hours. An administrator can setup working hours based on time zones. K2 will take into account the user’s business hours and calculate escalations based on the time zone.

  • K2 blackpearl introduction for a SharePoint programmer -1

    Earlier this year I worked on a process automation project for a start-up pharmaceuticals company. The client’s environment was MOSS 2007. They have developed several SharePoint designer based workflows, but were not satisfied with SharePoint designer experience. Quickly they realized that SharePoint Designer 2007 was good for developing simple workflows but when it comes to complex process automation (which is typical in a highly regulated pharma industry) SPD 2007 did not scale well. SPD 2007 provided limited workflow actions and the workflow developed in SPD 2007 cannot be reused.

    SharePoint Designer 2010 improved tremendously and has a much better workflow story but the client has not upgraded to 2010 yet.  Hence they bought and deployed K2 blackpearl.  

    K2 blackpearl is a very powerful workflow engine that is built on top of Microsoft technologies. Behind the covers, K2 uses .Net framework’s Windows Workflow Framework. K2 blackpearl has excellent integration with SharePoint technologies. In this post I touch upon the highlights and building blocks of K2 blackpearl.

    Several design surfaces:

    K2 blackpearl provides three design surfaces targeted to various skill sets and user profiles.

    Browser-based designer: This web-based designer available for end users/ power users / content owners within SharePoint sites. It is Silverlight based and has a very slick user experience.

    K2 Studio:  This is a Windows program similar to SharePoint designer. K2 Studio is typically used by Business analysts who are familiar with K2 technology.

    K2 Designer for Visual Studio: This is an extension to Visual Studio. Developers can write custom code and perform full debugging just like any other .Net program.

    K2 blackpearl is wizard based. Almost 90% of work that you would do in any design surface will be within the wizards. The wizards presented in any design surface look similar.

    Building blocks:

    Process:

     A workflow is called as a “Process” in K2. You will start creating a new workflow by creating a new process.  A process designed in one design surface can be exported and opened in another design surface.

    Similar to any workflow technology, a process can be started automatically or manually by the end users.  During installation, K2 creates an IIS web site called as Workspace. Workspace provides several features and functionalities for administrators and end users. One of them is the ability to start a workflow manually.

    However the interesting part is starting a workflow based on certain event. This is where process wizard comes into picture. Using a process wizard, you can configure how to start a workflow automatically. K2 blackpearl provides 3 process wizards:

    InfoPath Process Wizard:

    Using this wizard, a process can be started when an instance of InfoPath form is submitted.

    SharePoint Events Process Wizard:

    The SharePoint Events Process wizard integrates a process with a particular event on a list or library. So, the workflow can be started on events for both lists and libraries and items in the lists. As an example, you can start a workflow when a new item is added to the list or when a column is added to the list.

    This wizard presents several common events like Item Added, Item Deleted etc. It also presents some advanced events like Item Attachment Added, Item Attachment Deleted etc.

    Events:

    Event is the fundamental unit of action within the K2 workflow. Each event has a wizard where you set the parameters and configure how it should behave. K2 provides several events out of the box. This is where the rich functionality of the k2 platform appears. K2 provides events for:  SharePoint, Active Directory, Microsoft Dynamics CRM and Exchange. What this means is that, you can add remove or edit data in any of the above systems in your workflow without writing complex code. All these features are not available in SharePoint workflows out of the box. You need to write custom code to access any of these systems.

    One of the requirements in my project was to send out an Outlook appointment to the user as a part of the workflow. Exchange event wizard provides this functionality out of box. You can send out an appointment or Exchange task without writing a single line of code.

    Activities:

    An activity is a container for one or more events. Business rules can be setup on an activity. Typically activities are decision points in your workflow. You can setup rules on activities to control the flow of the execution.

Powered by Community Server (Personal Edition), by Telligent Systems