For Date/Time fields:
The value of Date/Time fields can be retrieved a few different ways, depending on the date format you'd like to display. The following methods for converting date values to specific formats are supported:
toLocaleString()
- Displays a date type fully expanded with date and time.
toLocaleDateString()
- Displays a date type with just the date.
toLocaleTimeString()
- Displays a date type with just the time.
Examples:
toLocaleString():
=toLocaleString(@now)
: results vary based on user's locale, but en-us looks like 2/5/2019, 1:22:24 PM
toLocaleDateString():
=toLocaleDateString(@now)
results vary based on user's locale, but en-us looks like 2/5/2019
Reference: Column Formatting - Operators.
For People fields (Person or Group):
The people field object has the following properties (with example values):
{
"id": "122",
"title": "Kalya Tucker",
"email": "[email protected]",
"sip": "[email protected]",
"picture": "https://contoso.sharepoint.com/kaylat_contoso_com_MThumb.jpg?t=63576928822",
"department":"Human Resources",
"jobTitle":"HR Manager"
}
Note:
The @currentField.title
returns a person's name by default. However, if the person field's Show Field has been adjusted, it may change the value of the title
property.
For example, a person field with the Show Field configured as Department will have the person's department for the title
property.
Reference: Column Formatting - Special string values.
Solution For you:
- If ContactName field is Single Line of Text:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"href": {
"operator": "+",
"operands": [
"mailto:",
"[$Email]",
"?subject=Task status&body=Follow Up: Agreements.\r\n---\r\n",
"Dear [$ContactName]",
"\r\nJust writing to follow up on that agreement that has been sent on ",
"=toLocaleDateString([$StartDate])",
". Let me know if you have any questions."
]
}
}
}
- If ContactName field is Person or Group:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"href": {
"operator": "+",
"operands": [
"mailto:",
"[$Email]",
"?subject=Task status&body=Follow Up: Agreements.\r\n---\r\n",
"Dear [$ContactName.title]",
"\r\nJust writing to follow up on that agreement that has been sent on ",
"=toLocaleDateString([$StartDate])",
". Let me know if you have any questions."
]
}
}
}
Note: You can also use =toLocaleString([$StartDate])
instead of =toLocaleDateString([$StartDate])
if you want to add timestamp also in your email body.
ContactName
column? Single line of text or person or group?