How To: Link a SharePoint application's workflow to a secondary list or library

  • This content uses the legacy Nintex K2 for SharePoint app. For more information about using the Nintex Automation for SharePoint app, see Add 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 that starts with a SharePoint event, execute the SmartObject methods shown in this article to link a secondary list or library to a primary list or library.

Note: The approach described here is only for workflows started with an event in SharePoint, such as an item was added or a document was added. See Reuse workflows for information on linking workflows that start with a form.

In this topic, a utility workflow containing the sequence of Create Reference and SmartObject Method steps you call in order to link a secondary list or library's workflow to a primary list or library's workflow illustrates the recommended approach.

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). The same workflow starts when an item is added to any of these lists.

Steps

You first create your SharePoint matching lists, then create a K2 application using the primary list, creating SmartForms and a workflow. You then execute system SmartObject methods in sequence, in a utility workflow, to create the links between the workflow and your secondary list.

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 Create a workflow to perform the linking SmartObject method executions.

  1. Create two matching SharePoint lists.
    1. In SharePoint, create a custom list for the Employees of the USA region.
    2. Name the List Employees_US.
    3. Create the following columns:
      • Title, using column type Text.
      • Name, using column type Text.
      • Address, using column type Text.
      • Phone, using column type Number.

    4. Create another custom list for employees of the European Union region.
    5. Name the List Employees_EU.
    6. Create the same columns as you did in the Employees_US list.
  2. Appify your primary list. Create SmartForms and a workflow.
    1. For your Employees_US list, select the K2 Application icon from the list menu bar.
    2. Select the Create SmartForms option on the Create K2 Application page.
    3. Keep the default selection of Use K2 smartforms as the New, Edit, and Display forms for this list/library option.
    4. Select the Create Workflow option.
    5. Select the When the following events occur > An Item was added option.
    6. Click OK to finish creating the K2 application.
    7. The system creates SmartObjects, views, and forms for the list, then opens the Designer for you to design your workflow.
  3. Add a Send Email step and deploy your workflow.
    1. Drag a Send Email step onto the design canvas.

    2. Specify the subject and body as shown below:
    3. Deploy the workflow.

Create a workflow to perform the linking SmartObject method executions

To reuse your SharePoint workflow, create links between the workflow and your secondary list or library by executing system SmartObject methods. You can do this by creating a workflow that takes the Site URL and List IDs of your primary and secondary SharePoint lists or libraries and executes the SmartObject methods in sequence. You could do this manually but it's easier to create a utility workflow with a SmartForm and use this for linking secondary lists or libraries.

  1. Create a SmartObject for the SmartForm input properties. The primary and secondary Site URLs and Site IDs.
    1. In the Designer, create a SmartObject named WF_Linking_SmO. See the How To: Create A SmartBox SmartObject article of the How To: Build a Simple Application series for steps on creating a SmartObject.
    2. Add Primary Site URL, Secondary Site URL, Primary List ID and Secondary List ID text properties.
    3. Click Finish to create the SmartObject.
  2. Create the input View from the SmartObject.
    1. Select Design a new View from the SmartObject page. See the How To: Create an Item View and a List View article of the How To: Build a Simple Application series for steps on creating views.
    2. Specify WF_Linking_View as the name, select your category, keep Item View as the view type, then click Create.
    3. Select Create Labels and Controls for the view.
    4. Select to include Primary Site URL, Secondary Site URL, Primary List ID, Secondary List ID fields names for the layout, and the standard Create method as the button.
    5. Once the view shows, select the Create button and change the Name and Text properties to Link as shown below:
    6. Your view should look like this:
    7. Select Finish to save your view.
  3. Create a Form from your view.
    1. Select Design a new Form from the view page. See the How To: Create a Form article of the How To: Build a Simple Application series for steps on creating forms.
    2. Specify WF_Linking_Form as the name and a description as shown below:
    3. Click Create.
    4. Specify Copy in the Site URL and List ID values as the form title.
    5. Click Finish.
  4. Create a Workflow using the form, starting the workflow when you click the Link button.
    1. Select Design a new Workflow from the form properties page. See the How To: Create a Workflow article of the How To: Build a Simple Application series for steps on creating workflows.
    2. Specify WF_Linking_WF as the workflow name.
    3. Expand the start event and click Edit to configure how the workflow starts.
    4. Select Do it for me! and click Next.
    5. Click Next.
    6. Click Save and Finish to complete the start event configuration.
    7. Click OK.
  5. Add a Create Reference step to get the SharePoint Integration Setting properties of the primary list . You use properties from this reference in later steps.
    1. Drag a Create Reference step from the Basic steps onto the design canvas.
    2. Name the Create Reference step Get primary SP Integration Settings.
    3. For the SmartObject, navigate to System > SharePoint 2013 Integration and select the SharePoint Integration Setting SmartObject.
    4. Click OK.
    5. Select LoadWithoutID as the SmartObject method.
    6. Add SiteURL and ListID as input mappings.
    7. Expand the context browser and drag and drop Primary Site URL and Primary List ID from the WF_Linking_Smo SmartObject reference to the matching input properties.
    8. Click Create to reference your output mappings. Name the reference Get primary SP Integration Settings.
  6. Add a SmartObject Method step to create a new Settings ID for your secondary list using properties from the SharePoint Integration Settings of the primary list. Each secondary list linked to a workflow has a unique Setting ID used to bind the events and workflow. The SharePoint Integration Setting SmartObject's Create method returns this new Setting ID.
    1. Drag and drop a SmartObject Method from the Basic steps to the design canvas.

    2. Name the SmartObject Method step Create secondary SP Integration Settings.
    3. Connect the step in the workflow.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Setting .
    5. Select Create for the method.
    6. Drag and drop the Secondary Site URL and Secondary List ID from the WF_LinkingInputs_SmO SmartObject reference to the SiteURL and ListID input properties.
    7. Drag and drop the List Display Name from the Get primary SP Integration reference.
    8. Add the following properties to the input mappings by clicking the plus (+) under the last input property:
      • CreateSmartObjects
      • CreateForms
      • CreateWorkflows
      • CreateStartForm
      • CreateEditForm
      • CreateDisplayForm
      • FormSubmitted
      • EventOccured
      • Manual
      • SmartObjectName
      • DocumentLibrary
      • FormResetVersion
    9. Drag and drop the matching properties from the Get primary SP Integration reference:
    10. Select Create a Reference from output mappings.
    11. Click Create and specify Secondary SP Integration Settings as the name.
  7. Add a Create Reference step to get the SharePoint event of the primary list.
    1. Drag a Create Reference step from the Basic steps onto the design canvas.
    2. Name the step Get primary SP Event.
    3. Link the step to the previous SmartObject Method step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Settings Events.
    5. Click OK.
    6. Select Get List as the Method.
    7. Select SharePoint Integration Setting ID as the identifier.
    8. Add SharePoint Integration Setting ID to the input properties.
    9. Drag and drop the ID from the Get primary SP Integration Settings reference to the SharePoint Integration Setting ID input property.
    10. Click Create Reference in output mappings and specify Get primary SP Events as the name.
  8. Add a SmartObject Method step to create the linked SharePoint event for your secondary list using your secondary list's Setting ID.

    1. Drag and drop a SmartObject Method from the Basic steps to the design canvas.
    2. Name this step Create secondary SP Events.
    3. Connect this step to the previous Create Reference step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Settings Events.
    5. Select Create for the method.
    6. Drag and drop the ID from your Secondary SP Integration Settings reference to the SharePoint Integration Settings ID input property.
    7. Drag and drop the SharePoint Integration Event ID from your Get primary SP Events reference to the SharePoint Integration Event ID input property.
  9. Add a Create Reference step to get the workflow registry for the primary list.
    1. Drag a Create Reference step from the Basic steps onto the design canvas.
    2. Name the step Get primary WF Registry.
    3. Link the step to the previous SmartObject Method step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Workflow.
    5. Select Get List for the method.
    6. Select Id for the identifier.
    7. Add SettingId to the Input properties
    8. Drag and drop Id from your Get primary SP Integration Settings reference to the SettingsId input property.
    9. Click Create Reference in output mappings and specify Get primary WF Registry as the name.
  10. Add a SmartObject Method step to create the secondary list's workflow registry
    1. Drag and drop a SmartObject Method from the Basic steps to the design canvas.
    2. Name this step Create secondary WF Registry.
    3. Connect this step to the previous create reference step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Workflow.
    5. Select Create for the method.
    6. Drag and drop the Secondary Site URL and Secondary List ID from your WF_Linking_SmO reference to the matching input properties.
    7. Drag and drop Id, WorkflowName, Status, StartType, SmartObjectName, and DocumentLibrary fields from your Get primary SP WF Registry reference to the matching input properties.
  11. Add a Create Reference step to get the primary workflow event.
    1. Drag a Create Reference step from the Basic steps onto the design canvas.
    2. Name the step Get primary WF Event.
    3. Link the step to the previous SmartObject Method step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Workflow Event.
    5. Select Get List for the method.
    6. Select SettingId;WorkflowId for the identifier.
    7. Add SettingID to the input properties.
    8. Drag and drop the Id field from your Get primary SharePoint Integration Settings to the SettingId input property.
    9. Click Create Reference in output mappings and specify Get primary WF Event as the name.
  12. Add a SmartObject Method step to bind the secondary list's workflow event using the secondary list's Setting ID.
    1. Drag and drop a SmartObject Method from the basic steps to the design canvas.
    2. Name this step Create secondary WF Event.
    3. Connect this step to the previous create reference step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Workflow Event.
    5. Select Create for the method.
    6. Drag and drop the Id field from your Secondary SP Integration Settings reference to the SettingID input property.
    7. Drag and drop WorkflowId and Event from your Get primary WF Event reference to the matching input properties.
  13. Add a Create Reference step to get the primary SharePoint management event. This is the event method from your SharePoint service object.
    1. Drag a Create Reference step from the basic steps onto the design canvas.
    2. Name the step Get primary SP Management Event.
    3. Link the step to the previous SmartObject Method step.
    4. For the SmartObject, navigate to SharePoint 2013 > [your SharePoint site] > Management and select Event.
    5. Click OK.
    6. Select Get Event Receivers as the method.
    7. Select EventReceiverID as the identifier.
    8. Drag and drop Primary List ID from your WF_Linking_SmO reference to the List ID input property.
    9. Click Create Reference in output mappings and specify Get primary SP Management Event as the name.
  14. Add a SmartObject Method step to create the secondary list's SharePoint Management event.
    1. Drag and drop a SmartObject Method from the Basic steps to the design canvas.
    2. Name this step Create secondary SharePoint Management Event.
    3. Connect this step to the previous Create Reference step.
    4. For the SmartObject, navigate toSharePoint 2013 Integration > [your SharePoint site] > Management and select Event.
    5. Select Register Remote Event for the method.
    6. Drag and drop the Secondary List ID field from your WF_Linking_SmO reference to the List ID input property.
    7. Drag and drop the Event field from your Get primary WF Event reference to the Remote Receiver Types input property.
    8. Drag and drop the Remote Event Receiver URL from your Get primary SP Management Event reference to the Remote Event Receiver URL and Extra Data input properties.
  15. Add a SmartObject Method step to link the secondary list's SharePoint events to the workflow.
    1. Drag and drop a SmartObject Method from the Basic steps to the design canvas.
    2. Name this step Register secondary SP Events to WF.
    3. Connect this step to the previous create reference step.
    4. For the SmartObject, navigate to System > SharePoint 2013 Integration and select SharePoint Integration Helper Methods.
    5. Select Register Remote SharePoint Events for the method.
    6. Add SiteURL, ListId, RemoteReceiverType, and RemoteEventReceiverURL input mappings.
    7. Drag and drop Secondary Site URL and Secondary List ID from your WF_Linking_SmO reference to the matching input properties.
    8. Drag and drop the Event field from your Get primary WF Event reference to the RemoteRecevierType input property.
    9. Drag and drop the Remote Event Receiver URL field from your Get primary SP Management Event reference to the RemoteEventReceiverURL input property.
  16. Add a Send Email step to conclude the workflow. This email notifies you that the linking SmartObject methods have completed.
    1. Drag a Send Email step onto the design canvas.
    2. Connect this step to the previous SmartObject Method step
    3. Specify the subject and body as shown below.
  17. Deploy your workflow and use the SmartForm to create the links between your primary workflow and secondary list.
    1. Click File > Deploy.
    2. Once your workflow is deployed, run the WF_Linking_Form SmartForm.
    3. Paste the Site URL and List IDs of your primary and secondary lists.
    4. Click Link.
    5. You should receive the notification email from the workflow final step.
    6. You can add a new item to your secondary list and the workflow associated with the primary list starts.
Review

In this article you create a utility workflow to execute a sequence of SmartObject Method steps to create links between the workflow of your primary SharePoint list and a secondary SharePoint list.