Forum Discussion
Strange behaviour of Lookup hyperlink
Hello Avian,
I used following json code in lookup column formating, it is working as expected. But I am still wondering if that on viewform.aspx and if you click on lookup hyperlink, it still asking for selecting for adding or removing in viewforn, which should not correct. If you are on viewform.aspx you can view the item on click on hyperlink, you should not be allowed to select value from lookup column. Is this bug? This was working correcttly in SP2016.
Anyway here is the json code, hope it will help someone.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"forEach": "lookupIterator in @currentField",
"elmType": "a",
"style": {
"padding-right": "=if(loopIndex('lookupIterator') == length(@currentField) - 1, '0px', '5px'"
},
"txtContent": "=if(loopIndex('lookupIterator') == length(@currentField) - 1, [$lookupIterator.lookupValue], [$lookupIterator.lookupValue] + ', ')",
"attributes": {
"target": "_blank",
"href": "='https://tenantname.sharepoint.com/sites/TestR/Lists/Libreria/DispForm.aspx?ID=' + [$lookupIterator.lookupId]"
}
}
]
}
Hello Avian,
Seems you are overlooked following option from list advanced setting, only need to change this setting
No json required until you want open lookup dispform in another tab. Finally the issue is resolved.
Hope this helps someone.
Avian