SharePoint Designer workflow Create and Update List Item actions

Learn how you can use the Create List Item and Update List Item actions to create a SharePoint list item and then update one or more of its fields in the same SharePoint Designer 2013 workflow.

ADVERTISEMENTS

SharePoint Designer 2013 comes with the following List Actions you can use to create and update SharePoint list items from within a workfow:

Create List Item

This action creates an item in a SharePoint list and returns the GUID of the item created. You can use the GUID returned by the Create List Item action in for example an Update List Item action to update fields in the newly created SharePoint list item. When you add a Create List Item action to a SharePoint workflow, the following sentence is displayed:

Create item in this list (Output to Variable: create)

where the create variable is of type Guid.

Example:

If you have a SharePoint list named MyList in which you want to create a new list item, you would have to configure the Create List Item workflow action as follows:

Create item in MyList (Output to Variable: create)

Note that you can use the Create New List Item dialog box to set the values of fields in the newly created SharePoint list item.

Update List Item

This action updates the values of one or more fields of an item in a SharePoint list. You can either update the values of fields in the SharePoint list item the workflow is currently running on or perform a lookup for an item to update in another SharePoint list. When you add this action to a SharePoint workflow, the following sentence is displayed:

Update item in this list

Example:

If you have a SharePoint list named MyList in which you want to update one or more fields, you would have to configure the Update List Item workflow action as follows:

Update item in MyList

Note that you can use the Update List Item dialog box to set the values of fields in a SharePoint list item that is either the current list item the workflow is running on or an item in a totally different SharePoint list on the same site where the workflow is running.

Example of using the Create List Item action with the Update List Item action

When you use the Create List Item action, you can immediately set the values of fields of the newly created SharePoint list item.

However, if you have a condition that needs to be met before you can set the value of a field in the newly created SharePoint list item, you must:

  1. Check for the condition and temporarily store the results in a workflow variable.
  2. Use the Create List Item action to create a new SharePoint list item.
  3. Use the value of the workflow variable to set the value of the field via the Create New List Item dialog box.

Or, you can:

  1. Use the Create List Item action to create a new SharePoint list item.
  2. Check for the condition, and if the condition is met, use the Update List Item action to perform a lookup in the newly created list item and set the value of a field based on the condition.

The second scenario is demonstrated below.

Suppose you have two SharePoint lists named List1 and List2. List1 has one column named Title, and List2 has 2 columns named Column1 and Column2.

When you add an item to List1, you want to use its Title to create a new list item in List2, but if the Title entered for the item in List1 is equal to "Apple", you want the text "Are you red?" to appear in Column2 of the newly created SharePoint list item.

To create such a solution:

  1. In SharePoint Designer 2013, create a new SharePoint workflow and associate it with the List1 SharePoint list.
  2. Add a Create List Item action to the workflow.
  3. Click this list in the workflow action.
  4. On the Create New List Item dialog box, select List2 from the List drop-down list box.
  5. Select Column1 in the list of fields, and then click Modify.
  6. On the Value Assignment dialog box, click the second button behind the To this value text box.
  7. On the Lookup for Single line of text dialog box, leave Current Item selected, select Title from the Field from source drop-down list box, and click OK.
  8. On the Value Assignment dialog box, click OK.
  9. On the Create New List Item dialog box, click OK.
  10. Add an If-condition to the workflow, and configure it to say:

    If Current Item: Title equals Apple
  11. Within the If-branch, add an Update List Item action to the workflow.
  12. Click this list in the workflow action.
  13. On the Update List Item dialog box, select List2 from the List drop-down list box, and then click Add.
  14. On the Value Assignment dialog box, select Column2 from the drop-down list box, enter Are you red? in text box, and click OK.
  15. On the Update List Item dialog box, select GUID from the Field drop-down list box, and then click the second button behind the Value text box.
  16. On the Lookup for String dialog box, select Workflow Variables and Parameters from the Data source drop-down list box, select Variable: create from the Field from source drop-down list box, and click OK.
  17. On the Update List Item dialog box, click OK.
  18. Add an End of Workflow action to the workflow if you created a SharePoint 2013 workflow.
  19. Configure the workflow to start automatically and then publish it.

In SharePoint 2013, navigate to the List1 SharePoint list and add a new item. Enter Banana in the Title field and click OK. Add a second SharePoint list item that has Apple as its Title. Wait until the workflow has run and completed on both items, and then navigate to the List2 SharePoint list. Verify that Are you red? appears in Column2 of the SharePoint list item that has Apple in its Column1 field.

Related Articles

ADVERTISEMENTS