Knowledge.ToString()

InfoPath: Conditionally Hide Hyperlink Control

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”.

Solution

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

substring(String/Node,1,(Boolean Condition)*string-length(String/Node))

Here Boolean Condition evaluates to 0 or 1 and hence the substring function will return either blank string or  String/Node value.

You may download InfoPath template example for conditionally hiding hyperlink control.

Share

Comments

One response to “InfoPath: Conditionally Hide Hyperlink Control”

  1. thomas Avatar
    thomas

    thank you! i couldn’t believe MS did not include this functionality!?!?!?

Leave a Reply

Your email address will not be published. Required fields are marked *