Using SharePoint list formatting and Power Automate to create linked items (via LookUp field) in a related list

Recently I was asked by a community member how to create a linked issue item (via LookUp field) using SharePoint list formatting. Via pure list formatting, it’s not possible to implement such functionality.

But we can use List Formatting to create a button that triggers a Power Automate flow and this flow creates a linked issue as below:

Check out how to implement this functionality in this post.

Create an Issues list

Create a new SharePoint list using the Issue Tracker template from the standard SharePoint list templates:

Add a LookUp field in the issues list to link to the source list where you are linking the issue:

Creating the Flow

Create the Flow using the ‘For a Selected Item’ SharePoint trigger.

Add as input parameters an ‘Issue Priority’ field as a Drop Down and add the equivalent values to what the Issues list has in the Priority field:

Add also two other input fields, one to capture What was the issue, and another to capture the issue description (Please give a better description of the issue)

The next step is to create an item on the Issues list, using as parameters the values from the flow inputs + ID of selected item in your source list:

Flow permissions

After you save your flow, head into the details page, and enable permissions for the list in the Flow (which allows anyone with permissions to that list to trigger it):

In the connections used piece, if you select ‘Provided by run-only user’, the user will need to have permissions in the issues list to log an issue. Otherwise if you select ‘Use this connection’, it will use your connection in Power Automate when running the flow.

Retrieve the Flow reference Id

In the Flow details page, click Export/Get flow identifier:

Copy the flow id (this includes the environment id too, so you can trigger flows from any environment if needed):

Add the button to create an issue

In the source list (where we will trigger the issue creation), select the column where you want to add the button, and apply the following list formatting JSON.

Note that the flow setup is done by adding a customRowAction element with an action tpe of executeFlow, and inside the actionsParams property we can setup the id of the flow, a header text and a custom ‘Run Flow’ button text:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\":\"v1/a3522f2e-f6fa-e55d-aece-8dff3e6b9f0a/396ba5a6-5aaf-4a1e-94a2-1731b69bb0b5\", \"headerText\":\"Please enter the Issue details\",\"runFlowButtonText\":\"Create Related Issue\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary  ms-fontWeight-semibold"
  },
  "style": {
    "text-decoration": "none",
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "CircleAdditionSolid"
      },
      "style": {
        "margin-right": "0.25rem"
      }
    },
    {
      "elmType": "span",
      "txtContent": "New Issue"
    }
  ]
}

Results

When clicking the button added to the list column, the initiating form of the flow will be triggered:

And when you click ‘Create Related Issue’, the flow will run and the linked issue will be created:

References:

customRowAction element

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *