cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Rule to hide based on value of control inside repeater?

Jump to solution

Is there any way to hide a control if a control inside a repeater is selected? , I can hide it if a =="Nurse" but if I add another row and select "diet" in that control, value of the control (displayed in a calculated value) now looks like "Nurse;Diet" and any additional rows just add to that. I want to hide a control if Nurse is selected in any of those but I'm not really seeing a way to do so. Any ideas?

0 Kudos
Reply
11 Replies
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

I assume that you want to hide a Control outside of a Repeating Section, but use the controls that are inside of a Repeating Section to base your arguments off of. yes? 

If that's the case, then using the following code in a Formatting Rule should accomplish what you're trying to do: 

(function(repeaterControls, valueToHideOn){
  var matchExp = new RegExp(valueToHideOn, "gi");
  return repeaterControls.filter(function(controlValue){
    return controlValue.match(matchExp) !== null;
  }).length > 0;
}(referenceToTheRepeatingSectionControl, "Nurse"))

Note: Because I have used .match() instead of just testing for equality, this isn't a particularly strict rule. If you require it to be more strict, or you have a word appear as a substring to one of the values being processed, then it might be better to use: 

(function(repeaterControls, valueToHideOn){
valueToHideOn = valueToHideOn.toLowerCase();
  return repeaterControls.filter(function(controlValue){
    return controlValue.toLowerCase() === valueToHideOn;
  }).length > 0;
}(referenceToTheRepeatingSectionControl, "Nurse"))

Does this help you to solve your problem? 

0 Kudos
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

Hi,

You can add a hidden calculated value inside repeating section and set value = "1" if a == "Nurse" and "0" if a != "Nurse".

Let's suppose that the name of the control is X.

Then add a calculated value named Y outside repeating section with formula = Sum(X).

Now if Y > 0 then hide your control.

BR,

0 Kudos
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

use formatting rule with formula like

inArray(NamedControlFromRepeater,"Nurse")
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

I was thinking of doing something like this but the drop down I'm evaluating has 80+ options. That's a lot controls/rules to add.

0 Kudos
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

This doesn't seem to work for me and I think it's because the control is a lookup. When I use this for a text field it works fine. 

Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

Yo N J‌, are you trying to hide a control that is outside of the repeating section based on the selections made of controls that are inside the repeating section? 

Does this rule do what you're trying to do? 

Can you include a screenshot to maybe help me understand if I have it wrong? 

0 Kudos
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

I promise I'm not ignoring you! I was looking over your post as you posted your second one  

I'll be honest, I tried the others first because they were a little quicker to attempt haha.

You're correct, I'm trying to hide controls outside of the repeater, based off a list lookup control inside the repeater.

0 Kudos
Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

After seeing Marian's rule, and now knowing what you're working with, I'd just use a modified version of: 

inArray(parseLookup(someLookup), "Nurse")

or, for a visual: 

Reply
Workflow Hero

Re: Rule to hide based on value of control inside repeater?

Jump to solution

Ah ha! That works. Thanks Marian Hatala‌ and nmarples

Reply