How To: Modify a Workflow to Link an Application's Start Rule to a Secondary List or Library
-
This content uses the legacy Nintex K2 for SharePoint app. For more information about using the new Nintex Automation for SharePoint app, see Adding the App.
You can reuse artifacts with other lists and libraries, as long as those other lists and libraries match the primary list or library's structure. To reuse a K2 for SharePoint application's workflow, use this article to modify your workflow to include parameters that allow the same workflow to be used in different (but matching) lists or libraries.
Note: The approach described here is only for a workflow which starts when a SmartForm is submitted. It does not apply to workflows started with an event in SharePoint, such as item/document added. See Reusing K2 for SharePoint Workflows for information on linking workflows that start with an event in SharePoint.
Scenario
You have regional staff employee lists (Employees_US, Employees_EU, and Employees_APAC) in SharePoint, the data structure of the lists is the same, and they are on the same SharePoint web application. You appify a primary list (Employees_US) with SmartObjects, SmartForms, and a workflow, and then reuse the SmartForms and workflow with your secondary lists (Employees_EU and Employees_APAC). See How To: Create a SmartForm to Link an Application's SmartForms to a Secondary List or Library .
Steps
You first create your SharePoint matching lists, then create a K2 application using the primary list, creating SmartForms and a workflow. You then modify your workflow to include the Site URL, List ID, and Item ID parameters and recreate item references. Finally, you update the SmartForm's start rule to use those parameters.
Setup Steps
The following steps set up the scenario from start to finish. If you want to skip the setup steps and view the topic step, go to Modify the Workflow to use the K2 for SharePoint Reuse Parameters.
-
Create two matching SharePoint lists
- In SharePoint, create a custom list for the Employees of the USA region.
- Name the List Employees_US
- Create the following columns
- Title, using column type Text
- Name, using column type Text
- Address, using column type Text
- Phone, using column type Number
- Create another custom list for employees of the European Union region
- Name the List Employees_EU
- Create the same columns as you did in the Employees_US list
- Appify your primary list. This creates the artifacts to reuse.
- For your Employees_US list, select the K2 Application icon from the list menu bar
- Select the Create SmartForms option on the Create K2 Application page
- Keep the default selection of Use K2 smartforms as the New, Edit, and Display forms for this list/library option
- Select the Create Workflow option
- Keep the default selection of Specify how the workflow gets started > When a SmartForm is submitted > Form: New Employees_US
- Click OK to finish creating the K2 application
- The system creates SmartObjects, views, and forms for the list, then opens the Designer for you to design your workflow.
Modify the Workflow to use the K2 for SharePoint Reuse Parameters
To reuse your workflow, replace the existing K2 for SharePoint application SmartObject Item References in the workflow with a new reference containing the Site URL and List ID parameters. Then modify the start rule of the SmartForm to use the new parameters.
- Configure your workflow start event with default options. Take note of the SmartForm and rule action
- Expand the start event and click the Edit link in the How will this workflow be started? section
- Keep the default selections, but make a note of the SmartForm, action and rule , which you will be editing
- Expand the start event and click the Edit link in the How will this workflow be started? section
- Remove the existing item references
- Expand the Context Browser
- Right click the Employees_US item reference and select Delete
- Do the same for Employees_US Attachments item reference
- Add three variables for the Site URL, List ID, and Item ID parameters. You use these in the new item references and in the SmartForm start rule
- In the Context Browser click the Add link in the variables area
- Add Text variables for Site URL, List ID, and Item ID
- Create and configure a reference event for the Employees_US SmartObject. The original reference did not have the Site URL and List ID parameters
- Drag a Create Reference step from the basic steps onto the design canvas
- Click the SmartObject drop down and navigate to your SharePoint folder and select Employees_US
- Select the Get List Item By ID method
- Add Site URL and List ID input properties
[to do] - Drag the Item ID, List ID, and Site URL variables from the context browser into the matching input mappings
- Click the output mappings Create
- The Employees_US reference is created
- Create a second reference event, this time for the Employees_US Attachments SmartObject
- Drag a Create Reference step from the basic steps onto the design canvas
- Click the SmartObject drop down and navigate to your SharePoint folder and select Employees_US Attachments
- Select the Get Attachments method
- Add Site URL and List ID input properties, then remove the Name (LinkFilename) property (as the Item ID is used for identity)
- Drag the Item ID, List ID, and Site URL variables from the context browser into the matching input mappings
- Click the output mappings Create to create the Employees_US Attachment reference
- Drag a Create Reference step from the basic steps onto the design canvas
- You have configured this workflow with the K2 for SharePoint artifact reuse parameters. Add a Send Email step to complete the workflow.
- Drag an email step onto the design canvas
- Configure the step with the following details
- Deploy the workflow
- Drag an email step onto the design canvas
-
Update the SmartForm rule that you took note of in Step 3 to use the data fields from the workflow instead of the item references you deleted.
- Locate and edit the New Employees_US form.
- Select the Rules tab of the SmartForm. Note the red exclamation mark
- Select New Employees_US > On New Emplyoees_US, when Save Button is Clicked
- Locate the then start the ... Workflow action and click configure
- Deselect the previously-configured item references
- Drag the ID field from the Employees_US SmartObject in the context browser to the Item ID workflow data field
- Drag the List parameter from the New Employees_US view to the List ID workflow data field
- Drag the RootWebUrl and SubsiteRelativeUrl parameters to the Site URL workflow data field. These two parameters form the full Site URL
- Click Finish to save your changes
- Check the form in
You can now link the SmartForm to a secondary list or library. See Reuse K2 for SharePoint SmartForms for further information and the steps to create those links. Once the SmartForm is linked, adding a new item starts the workflow.
- Locate and edit the New Employees_US form.
Review
In this article you modified your K2 for SharePoint application workflow to use the Site URL and List ID reuse parameters and updated the When the form is submitted rule of the SmartObject to use the parameters.