Hiding a Label if the Associated Control in Empty in Task Form

  • 14 February 2018
  • 5 replies
  • 50 views

Badge +3

Hello

I know I can use isNullOrEmpty({Self}) to not show the control in the approval task form, but the label still shows. Is there a way (easily, not doing a different rule on each label or grouping the label and control in a panel) to say if control is empty then hide label and control.


5 replies

Userlevel 5
Badge +13

Hi Andrew,

You can apply one rule to multiple controls. So you can apply the rule that you have on the control to the label also.

Just open up the form in the designer and click on the Rules button in the Ribbon. In the Rules panel, check the "Show all" box to show all the form rules. Then select the label, find the rule you applied to the control, and click on the drop down for that rule. You will see an option to "Add to selected controls", which will add it to the label you selected.

Nintex Forms - Apply Rules to Controls

You can also check which rules are applied to which controls by finding the rule in the rules panel and selecting "Select associated controls" for the rule drop down menu.

Badge +3

Hi Eric

This is what I did as I was under the assumption this was the behavior. I created the rule and associated to all the controls so when the approval happens the task form is only showing the fields that have a value and the others including labels are hidden. This is the rule with one of the label selected and the control with a screen shot of the Preview page.

213415_pastedImage_2.png

213419_pastedImage_3.png

Userlevel 5
Badge +13

Looks like using the {Self} option won't work on the label controls, so I suggest using the Named Control. Create a rule and enter the condition as something like isNullOrEmpty(Supplier Name). Then you can apply it to the control and the label. You'll probably have to create two separate rules -- one for each control/label set.

Badge +3

That's what I was afraid of. I was hoping there would be a way of saying isNullOrEmpty{Associated Control} and I could then apply to all the label fields.

Thanks for your inputs. 

Userlevel 5
Badge +14

While you can discover which control a label has been connected to via the 'for' attribute on the innermost label element, there is no way to trigger a rule based off of that connection without explicitly referencing the connected control in question... which doesn't get you any closer to making a one-size-fits all rule. 

That being said, you could in theory create a function that runs after the form has loaded, and simply generates an event for each label based off of that [for] attribute that will run when the connected control has been changed, and instead of doing any styling from within it, triggers a generic rule on the label applying the appropriate style. 

However it seems like it would be easier to just either hide using a rule that references the connected (Named) control outright, or hiding the panel that contains both label and control.


Reply