Converting Documents using K2 Designer Workflow

This is the third blog in our ongoing K2 Cloud with Muhimbi Online series. In this article, we will build our first K2 workflow.

Prerequisites/Before we begin:

  • Please make sure Muhimbi Converter Service Online Integration facilities and K2 SmartObjects has been configured.
  • Appropriate privileges to K2 Management portal, K2 Designer, and SharePoint Online.
  • Create a new Document Library named K2 Convert to PDF”  in a site collection.
  • The individual should have intermediate knowledge of SharePoint and basics of Building a K2 workflow.

Now that we have all the Prerequisites in place let’s start building our First ‘Convert to PDF’ K2 workflow.


STEP 1: Open K2 Designer and Click on CREATE “Workflow“.

Designer.jpg

STEP 2: Enter the Name of your Workflow and Click on ‘CREATE‘.

CREATE.jpg

STEP 3: On the Workflow Designer Canvas, Double-click on ‘Start Event‘ > The ‘Start Event‘ configuration blade opens > Click on ‘Start with a SharePoint List’.

Start Event.jpg

Step 3.1: Select the SharePoint Online Document Library (data source).

In the screenshot below “K2 Convert to PDF” is the name of the SharePoint Online Document Library.

data source.jpg

Step 3.2: Select the Workflow List Trigger.

For our demo we will set it to “Workflow is manually started” and click on NEXT.

Workflow is manually started.jpg

Step 3.3: Click on “SAVE AND FINISH”. See the screenshot below.

SAVE AND FINISH


Step 4: On the SmartObjects search bar, search for “Muhimbi Convert to PDF” (the smart object we created in the previous blogs).

Drag and drop the smart object to the K2 workflow canvas.

Canvas.jpg

Step 5:

  • Double-click on the “Muhimbi Convert to PDF” SmartObjects.
  • The “Muhimbi Convert to PDF” SmartObjects configuration blade opens.
  • METHOD: Serialize
  • Add the Input Mappings (properties) by click on the (Please refer to the screenshot below).

Muhimbi.jpg

Step 5.1:

  • Open the Context Browser and Navigate to “K2 Convert to PDF“.
  • Set the Source_file_Content to Document Content.
  • Set the Source_file_Name to Document Name (map the Input parameters with reference to screenshot below).
  • Set Output_format to Pdf.

Context Browser.jpg

Step 5.2: On the same screen(Context Browser) Add variable

  • Base_File_Name” of type Text.
  • Processed_File_Content” of type Text.

Map to the Data fields with reference to the screenshot below.

Context Browser 2.jpg

You have successfully configured the Muhimbi Convert the PDF SmartObjects in your workflow. 🙂


Step 6: On the SmartObjects search bar, search for “Add Document to Library”  and drag and drop the smart object to the K2 workflow canvas.

Add Document to Library

Step 6.1: On the Workflow Designer Canvas, double-click on “Add Document to Library”, Edit SmartField tab opens.

  • Expand the Context Browser.
  • Select the Function(ƒx).
  • Add the “Files Function” > “Get File From Content” with reference to the screenshot below.

Get File.jpg

Step 6.2: Drag and Drop

  • ‘Base_File_Name‘ Field to ‘Filename
  • Content‘ to ‘Processed_File_Content

See the screenshot below.

Configure Get File.jpg

Step 7: Click on the File Menu > Save and > Deploy the workflow.

Deploy.jpg

You have successfully created your First “Muhimbi Convert to PDF” workflow.


Let’s test our Workflow.

Step 8:  Navigate to the SharePoint Online document Library(K2 Convert to PDF), upload a document and run the K2 workflow.

SharePoint

Step 9: Select the workflow from the dropdown list and start the workflow.

K2 workflow.jpg

Now if you are running the workflow for the First time it will Error out.

K2 Error.jpg


Let’s troubleshoot the problem.

Step 10:

  • Navigate to K2 Management portal.
  • Expand Workflow Server > Workflows > Errors > All.
  • You will see “OAuth Token Expired and requires reauthorization” error.

Trouble Management.jpg

Step 10.1:

  • On the Error logs screen, click on “Show Details”.
  • “Full Details” modal box opens.
  • Copy the URL and paste in the new window.

Trouble Management 1.jpg

Step 10.2:

Authoziation.jpg

On Successfully Authorization, you will see the screen below.

Successful Authoziation.jpg

Step 12:  Navigate back to the SharePoint Online document Library(K2 Convert to PDF), run the K2 workflow(Step 8).

Workflow Test Sucess.jpg

Navigate back to the SharePoint Online document Library(K2 Convert to PDF), the document is created 🙂

New Site.jpg

Congrats you have successfully created your First K2 Convert to PDF workflow. 😀

Advertisements
Posted in K2

One thought on “Converting Documents using K2 Designer Workflow

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s