While the article doesn't list a lookup column as an unsupported field type to use for this purpose, it doesn't provide guidance on how to use one in this way, either. From my testing, you can't simply grab the value of a lookup field in the described way:
Forum Discussion
Aylarja
Apr 15, 2021Copper Contributor
Using JSON to Show/Hide Modern Form Field Based on Value Selected in Lookup Column
I am trying to modify the new-entry form of a modern list in SharePoint Online by hiding or showing a field based on the value selected in a preceding field on the same form. Microsoft offers straightforward guidance on how to do this using a JSON snippet.
=if([$LookupField]=='Hourly', 'true', 'false')
If I use a choice field instead of a lookup field, this works fine. But since I've got a lookup field, I did some more digging, and in some other contexts it looks like the value may be captured in a lookupValue property, so I tried it this way:
=if([$LookupField.lookupValue]=='Hourly', 'true', 'false')
But it doesn't work. Elsewhere someone said that by doing some debugging, it looks like the function is expecting this construction:
=if([$LookupField]=='1;#Hourly', 'true', 'false')
No errors, but still no luck. Does anyone know if it is possible to use the value from a lookup field in this way? And how would I do this?
Lookup fields are not supported in conditional formulas in SharePoint.
Source: can we show a column in a form based on a lookup field?
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.
Lookup fields are not supported in conditional formulas in SharePoint.
Source: can we show a column in a form based on a lookup field?
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.
- AylarjaCopper Contributor
ganeshsanap, thanks for responding to my question here as well as on StackExchange. Unfortunately, your answer didn't change from "no" to "yes" in between!
But everything I see confirms what you say: currently, it isn't possible to use the value of a Lookup field in this way. For anyone interested in this capability, I have created a UserVoice request for it.
Aylarja You're welcome!
Thanks for creating a UserVoice for this. But looks like the link to UserVoice is broken/wrong in your above reply.
So, I am adding the correct link below for anyone who wants to vote on your idea (I already voted!):
Enable the ability to hide SharePoint form fields based on the value of Lookup columns
Also, I have updated the documentation at: Show or hide columns in a list or library form
Please click Like if my post was useful to you in any way.