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“.
STEP 2: Enter the Name of your Workflow and Click on ‘CREATE‘.
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’.
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.
Step 3.2: Select the Workflow List Trigger.
For our demo we will set it to “Workflow is manually started” and click on NEXT.
Step 3.3: Click on “SAVE AND FINISH”. See the screenshot below.
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.
- 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).
- 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.
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.
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.
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.
Step 6.2: Drag and Drop
- ‘Base_File_Name‘ Field to ‘Filename‘
- ‘Content‘ to ‘Processed_File_Content‘
See the screenshot below.
Step 7: Click on the File Menu > Save and > Deploy the workflow.
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.
Step 9: Select the workflow from the dropdown list and start the workflow.
Now if you are running the workflow for the First time it will Error out.
Let’s troubleshoot the problem.
- Navigate to K2 Management portal.
- Expand Workflow Server > Workflows > Errors > All.
- You will see “OAuth Token Expired and requires reauthorization” error.
- On the Error logs screen, click on “Show Details”.
- “Full Details” modal box opens.
- Copy the URL and paste in the new window.
- Once you copy paste the link in the new tab, the link will redirect to https://api.muhimbi.com/auth/pages/Login.aspx.
- Enter your Username and Password and Click on the “Log in ” Button.
On Successfully Authorization, you will see the screen below.
Step 12: Navigate back to the SharePoint Online document Library(K2 Convert to PDF), run the K2 workflow(Step 8).
Navigate back to the SharePoint Online document Library(K2 Convert to PDF), the document is created 🙂
Congrats you have successfully created your First K2 Convert to PDF workflow. 😀