You may have been to a situation where you have to conditionally hide the hyperlink control but unlike many other InfoPath controls, hyperlink controls does not support conditions. But there is a way to hide this control. 🙂
Here is my main data source.
IsVisible is a boolean field and Hyperlink is a string storing URL. I want to show the URL only when IsVisible is “true”.
It is a very simple solution. If you know HTML, here is a hint.
HTML code <a href=”https://blog.vishalon.net”>Vishal’s Blog</a> will result in the actual hyperlink where as <a href=”https://blog.vishalon.net”></a> will result in the “hidden” hyperlink.
The same concept is applied here to hide the hyperlink control. Using my main data source, I will insert hyperlink control with following values
Display Data Source value is
substring("My Hyperlink",1,(my:IsVisible="true")*string-length("My Hyperlink"))
So for your code, you may use
Here Boolean Condition evaluates to 0 or 1 and hence the substring function will return either blank string or String/Node value.
Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1’s and 0’s from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.