JSON Conditional Formatting - Clickable Action - Email

Iron Contributor

I'm using the "standard code" for clickable actions  in my SharePoint List on an assigned to field .  I'm running into two issues and wondering if someone might be able to help. 

 

1.   The link I want to use has this at the end All%20Orders.aspx.  Therefore, the code I'm using,  that I will list below, is translating that into the "entire hyperlinkAll Orders.aspx" which is returning a 404 error as it should since it shows a space instead of a continuous hyperlink.  I tried just removing the space but that still does not work.  What can I do to correctly translate this hyperlink?

 

2. I'd like to include in the body the Title of the Record and the PO number which are dynamic fields based upon the row selected.  Is there a way I can include those and exclude the "Hey, how is your task coming along message?  I've tried various ways with no success.  

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"padding-right": "8px"
},
"txtContent": "@currentField.title"
},
{
"elmType": "a",
"attributes": {
"iconName": "Mail",
"class": "sp-field-quickActions",
"href": {
"operator": "+",
"operands": [
"mailto:",
"@currentField.email",
"?subject=Task status&body=Hey, how is your task coming along?.\r\n---\r\n",
"@currentField.title",
"\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=",
"[$ID]"
]
}
}
}
]
}

 

Thank you in advance. 

10 Replies

Hi @Cindy Zalme,

 

Are you still having issues? If so, can you share the list definition?

 

Norm

@Norman Young   Yes,Norman, and thank you so much!  Sorry, but I don't understand what you mean by list definition.  

@Cindy Zalme,

 

What is the structure of the list? Columns and data types etc.

 

Norm

@Norman Young It is quite a large list with Choice, lookup, Text, Number, People, etc.,  I was trying to add this email feature to an "Assigned To" column.  

@Cindy Zalme ,

 

I was only asking because I didn't want to guess at the column structure. I'll take a look and see if I can figure it out. No promises ;)

 

Norm

@Norman Young that was an "assigned to" out of the box.  

@Cindy Zalme   It does not have to, however, be an assigned to column.  Just a person lookup column. 

Hi @Cindy Zalme,

 

1. The link I want to use has this at the end All%20Orders.aspx. Therefore, the code I'm using, that I will list below, is translating that into the "entire hyperlinkAll Orders.aspx" which is returning a 404 error as it should since it shows a space instead of a continuous hyperlink. I tried just removing the space but that still does not work. What can I do to correctly translate this hyperlink?

Update the default code to reflect your list URL. Keep the "DispForm.aspx" so when a user clicks the link they go directly to the list entry. 

 

2. I'd like to include in the body the Title of the Record and the PO number which are dynamic fields based upon the row selected. Is there a way I can include those and exclude the "Hey, how is your task coming along message? I've tried various ways with no success.

For each list value you want to include add the following: 

"\r\nTitle column: ","[$Title]",

 

Sample image below for context.

Untitled.png

I hope this helps.

 

Norm

 

@Norman Young 

I followed your code suggestions but my link is breaking at the spaces in my list name where the % is inserted.  How do I correct this?

 

https://       .sharepoint.com/sites/IRXImplementationsOpsManagement/Lists/Reliability%20Commitments%20List/AllItems.aspx?

 

Thanks for any and all help!

Stephanie 

@Stephanie_Clark @Cindy Zalme This is not specific to SharePoint JSON formatting, it is specific to email client you are using.

To avoid breaking links with spaces in between in outlook, you can wrap links between angular brackets (<>) like: 

 

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding-right": "8px"
            },
            "txtContent": "@currentField"
        },
        {
            "elmType": "a",
            "attributes": {
                "iconName": "Mail",
                "class": "sp-field-quickActions",
                "href": {
                    "operator": "+",
                    "operands": [
                        "mailto:",
                        "[$Author.email]",
                        "?subject=Task status&body=Hey, how is your task coming along?",
                        "\r\n---",
                        "\r\nTitle= ",
                        "[$Title]",
                        "\r\nClick this link for more info. <https://contoso.sharepoint.com/sites/JSONFormatting/Lists/Reliability%20Commitments%20List/DispForm.aspx?ID=",
                        "[$ID]>"
                    ]
                }
            }
        }
    ]
}

 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.