cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rolanddaane
Helper II
Helper II

Use value of column in Json Formatting

I have a column (Review and Approval) which shows a button if the value is Start Workflow, and clicking it opens a flow in Power Automate. In the example below the ID of the power Automate Flow is 0123456789 (See below: Json code column Review and approval:) .

I need to have the result of a choice column instead of 0123456789. See below what I've tried (Idea I tried:).
I added a column Approval_Flow_ID, and replaced 01234567879 with [$Approval_Flow_ID], but the button doesn't show.
Any Idea's? THANXX

Json code column Review and approval:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "@currentField",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"01234567890"}"
},
"style": {
"background-color": "#008082",
"color": "white",
"border-radius": "0 15px",
"visibility": "=if((@currentField == 'Start Workflow'),'visible','hidden')"
}
}

Idea I tried:
Json code column Review and approval:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "@currentField",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"[$Approval_Flow_ID]"}"
},
"style": {
"background-color": "#008082",
"color": "white",
"border-radius": "0 15px",
"visibility": "=if((@currentField == 'Start Workflow'),'visible','hidden')"
}
}

rolanddaane_0-1640242056850.png

 





1 ACCEPTED SOLUTION

Accepted Solutions

I indeed didn't have it visable.
I'll try putting the Flow ID into the column that presents the button. If I format the color of the text the same as the body it should work.

I don't want to have the select column for the flow active because general users won't require it, and may switch off.

Thanks!

View solution in original post

7 REPLIES 7
leo85
Super User
Super User

Hi @rolanddaane ,

to me this question may better be posted in a SharePoint forum, but I'll give it a try.

 

Is the column "Approval_flow_ID" visible? In column formatting you can only access those columns that are currenly visible in the table. So if you have hidden the column "Approval_flow_ID", the other column cannot access it.

 

Additionally, you have a syntax error in your code. After "[$Approval_Flow_ID]" there is backslash missing. It should read '\"[$Approval_Flow_ID]\"'.

 

leo85_0-1640250694804.png

 

 

Regards,

Leo

 

---------------------------------------------------

If my answer solved your issue, please mark it as complete.

If what I wrote helped you, please give it a thumbs up.

I indeed didn't have it visable.
I'll try putting the Flow ID into the column that presents the button. If I format the color of the text the same as the body it should work.

I don't want to have the select column for the flow active because general users won't require it, and may switch off.

Thanks!

Hi @rolanddaane , did you get this working? I am facing the same scenario where I want to trigger a different flow from a button, based on the column value that contains the flow ID (@currentField).

 

I'm struggling to get the syntax right.

OliverR-82
Continued Contributor
Continued Contributor

After a bit more searching online I managed to get it working. The correct syntax for the customRowAction property is the following, in my case:

 

"customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + @currentField + '\"}'"
}

 

I was struggling to put it all together, and forgot the '=' sign. I hope this helps someone.

I tried that but that throws an unexpected end of Json error

Because I want to take the value from the column Approval_Flow_ID (and not @currentField, I need something like this....

"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\": \"' + [$Approval_Flow_ID] + '\"}'"
}

Hi @rolanddaane 

 

Funnily enough I was experimenting with just that scenario earlier this week. I got it to work with the following code, which looks to be exactly the same way as what you pasted. Just make sure that you're using the internal column name to reference the field (in my case it was 'FlowID')

 

 

"customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + [$FlowID] + '\"}'"
  }

 

If you're getting an "unexpected end of JSON" error maybe the problem lies elsewhere (forgot a comma, closing bracket or parentheses...).

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (1,815)