May 26 2023 06:30 AM
Hello,
at https://learn.microsoft.com/de-de/sharepoint/dev/declarative-customization/formatting-syntax-referen... I did find this for the split operator:
Now with that given - I use this:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=split([$Supervisor.email], '@')"
}
This returns: first.name,domain.com
It does what it should. However my question is how can I address the array? So for example that only the index 0 of the array will be returned? Means only: first.name
Or index 1 of the array, which would return only: domain.com
At the end I need all elements of the array to build a new string I need. I want to create a delve link of the user profile to be opened at a new browser tab. I have all working except the string rebuild of the email.
Side note: I have used the replace operator to solve my problem (not mentioned and shown here!)
But, I want to learn more and like to know, how to use the split operator and access each operand of the array individually.
Somebody knowing it and can explain?
Many thanks for teaching me in advance.
Cheers
JK
May 26 2023 07:03 AM
@_J-K_ try to use
"children": [
{
"elmType": "span",
"txtContent": "=substring(@currentField.email, 0, indexOf(@currentField.email,'@'))"
},
{
"elmType": "span",
"txtContent": "=substring(@currentField.email, indexOf(@currentField.email,'@'), length(@currentField.email))"
}
]
I haven't tested but you get more info from this link https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-referen...
Br,
Suvi
Please free to ask question, if this solves your purpose mark this as answered.
Jan 11 2024 07:09 AM
Solution
I couldn't find a way to access the resulting array either.
Like @suvi-15 pointed you can use the substring instead. But in this case, accessing another field requires this markup [$ColumnName] and not the @ColumnName
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"=substring([$Supervisor.email], 0, indexOf([$Supervisor.email],'@'))"
}
Additional note: I couldn't access a field that has a space in it.
ex.:
[$Supervisor Info.email] doesn't work.
[$SupervisorInfo.email] works.
Jan 11 2024 07:09 AM
Solution
I couldn't find a way to access the resulting array either.
Like @suvi-15 pointed you can use the substring instead. But in this case, accessing another field requires this markup [$ColumnName] and not the @ColumnName
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"=substring([$Supervisor.email], 0, indexOf([$Supervisor.email],'@'))"
}
Additional note: I couldn't access a field that has a space in it.
ex.:
[$Supervisor Info.email] doesn't work.
[$SupervisorInfo.email] works.