Question

List button to start workflow

  • 27 July 2023
  • 4 replies
  • 293 views

Userlevel 1
Badge +6

This might be a bit of an odd request, but I’m looking for a way to add a column to a list in Sharepoint 2019 which contains links or buttons (or ideally a custom icon that is a link button to visually show quickly what the workflow would do) that starts a specified list workflow on that item. I know I can add the list workflow to the item menu, but for users that aren’t particularly digitally proficient that option is somewhat obscure and easy to miss, prompting them to try other means of getting their results that are undesirable. Basically, I want a list that (simplified for clarity sake) looks like this:

 

Title Column of links (the one I’m asking about)
Item Apple Button that starts list workflow on Item Apple
Item Banana Button that starts list workflow on Item Banana

Item Peach

Button that starts list workflow on Item Peach
Item Strawberry Cake Button that starts list workflow on Item Strawberry Cake

 

The list workflow I want to start is connected to this list. I’m thinking perhaps it might be possible through JSON formatting the column, but I’m not sure how to do that for this case, I’d like to be able to set it up once and then it auto-generates the links when items are added.


4 replies

Userlevel 1
Badge +6

I can share what I have right now. Looking at the url belonging to the start form of the workflow, it is comprised of several portions:

  1. The site url
  2. a portion with layouts/NintexForms/InitiateWorkflow
  3. an identifier for the list in question
  4. The ID number (like ID= and then the number) of the list item
  5. An identifier for the workflow that goes like TemplateID= and then a code

I can build the total url in a workflow using the Build String Action, and then put that in a hyperlink column, which works and gives me the result I want. But it leaves several downsides:

  1. The need to add an extra workflow that triggers upon item creation, which always delays a bit before the hyperlink field is filled.
  2. The workflow needs to be run again if I want to apply this in a broader way and carry on other fields from the list row in the url that might actually change (unlike the ID of the item)

With that in mind, I was hoping that JSON formatting the column instead of using a workflow would add this dynamic updating I am looking for, at the only cost that the ID column has to stay in view (which isn’t a big deal I think). I have tried this JSON code on a hyperlink column:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"attributes": {
"href": "<site url here>_layouts/15/NintexForms/InitiateWorkflow.aspx?List={gibberish list identifier code here}&ID=[$ID]&TemplateID=gibberish identifier here",
"target": "_blank"
},
"txtContent": "LinkText"
}

The issue I have is that it doesn’t pull the actual value of the item ID into the url, it just leaves it as [$ID] in the url itself (even though the ID column is in the view). Everything else does seem to work, like filling the display text. Anyone have some more experience with JSON that can figure out what I’m missing so that it recognises that I’m trying to reference another column there?

I do know that if it puts the number there instead of the [$ID] I get the correct link and I can reach the Start form for the workflow through it.

Userlevel 4
Badge +12

@BobR 

I’ve used some column formatting to add edit button to launch a nintex form in edit more but not launch a workflow.

I was looking through the syntax reference and there is an example in the special string value section of using a location field:

Formatting syntax reference | Microsoft Learn

It has a different syntax for concattenating the href

 "href": "='https://www.bing.com/maps?cp=' + @currentField.Coordinates.Latitude + '~' + @currentField.Coordinates.Longitude + '&lvl=17&sV=2'",

But maybe trying the + @ID + might work?

or using internal field name format [!ID]

 

Userlevel 1
Badge +6

I’ve been trying to combine the url string like that as well, I’m starting to think that the issue is that Sharepoint can’t use the ID properly in calculations outside of flows. I wasn't sure if this applies to the JSON portion as well, but apparently it does. I tried a different approach, that is, using a calculated column with the entire link basically created in the calculations like a combined string, and then using JSON to hyperlink it. That worked for already existing items but left the ID reference empty for newly created items. I think I’m stuck with just creating it in a workflow that automatically runs on newly created items, and just re-running that workflow when a relevant column is edited to update the hyperlinks. It does leave users having to refresh the page after creating or editing an item to update the hyperlinks they get, but it might be the best option.

Userlevel 1
Badge +6

I want to ask something in relation to this. I have the hyperlink column in my list that links to the start form of my workflow. But users that have Read-only permissions on the item can apparently also start a workflow on the item. I was under the impression before that users would need Contribute permissions to start workflows. Is there a way to prevent users with read-only permissions on an item from starting list workflows on said item? I have tried looking in the workflow settings and for validation rules in the start form, but I can’t find anything that would check for a initiator’s or current user's permissions on the current item.

Reply