Want to only include a block of fields in a template if a certain condition is met

Hi, I have a block of data that appears in a template like this:

The PLr is determined to be <<[Letter]>>.

Severity of injury: <<[Severity of Injury]>>
Frequency: <<[Frequency]>>
Possibility of avoiding: <<[Possibility of Avoiding]>><<Start: SELECT(PlrTest[ID],[ID]=”6f711588”)>>
<<SWITCH([_THISROW].[ImageSelect],
1, [Image1],
2, [Image2],
3, [Image3],
4, [Image4],
5, [Image5],
6, [Image6],
7, [Image7],
8, [Image8],
""
)
>>
<<End>>

This PlrTest table has a field Counter that is a string when the required fields have been completed like "SFR".

I only want to display the above block of code in the template when it equals "SFR", otherwise nothing.

What code should I wrap it in please? I'm not sure, is this an IFS statement?

thanks for any help!
James

0 16 380
16 REPLIES 16

You can use <<IF:>> with this. Please check this article how you can use it. 
https://support.google.com/appsheet/answer/11568425?hl=en&sjid=5302213925100807615-EU

Thank you.

My problem is I'm a bit uncertain how to do an IF test when there are multiple values to look at.

I need to test a text field to see if it has one of eight possible values.

The logic is like this:

<<If: ([Counter] >= "Number1") OR ([Counter] >= "Number2") OR ([Counter] >= "Number3" ... (etc, up to Number8))>>
Write the paragraph
<<EndIf>>

Is IF the best solution for this please?

thanks.

Instead of using OR(), you can use IN([Counter],LIST("SFR","ASD",etc))

Thanks, I'll try it. Do I have to use START when I do that in a template?

That is difficult to know as you haven't describe what data the template should collect.

I'm trying to run a Select statement inside it, so the whole code block is something like this: (the template didn't execute with the In-Counter-List bit in it):

<<START: IN([Counter],LIST("SlightSeldomPossible","SlightSeldomUnlikely","SlightFrequentPossible","SlightFrequentUnlikely","SeriousSeldomPossible","SeriousSeldomUnlikely","SeriousFrequentPossible","SeriousFrequentUnlikely")>>
Determination of Required Performance Level (PLr)
Outcome of Test
The PLr for this machine is determined to be <<[Letter]>>.

Severity of injury: <<[Severity of Injury]>>
Frequency: <<[Frequency]>>
Possibility of avoiding: <<[Possibility of Avoiding]>>


<<Start: SELECT(Machine[MachineID],[MachineID]=”4ab1fa65”)>>
<<SWITCH([_THISROW].[ImageSelect],
1, [MapImage1],
2, [MapImage2],
3, [MapImage3],
4, [MapImage4],
5, [MapImage5],
6, [MapImage6],
7, [MapImage7],
8, [MapImage8],
""
)
>>
<<End>>

 

<<END>>

 

 

The Start: expression is used when you want to create a loop on a template where the result is a list. For example when you want to read all child records that belong to the parent. Also.. when using it, you need to read the key column, otherwise it won't work.

OK thanks.

So how do I execute a block using the Counter List as a condition? I've also tried it with If and that doesn't run either?

 <<IF: IN([Counter],LIST("SlightSeldomPossible","SlightSeldomUnlikely","SlightFrequentPossible","SlightFrequentUnlikely","SeriousSeldomPossible","SeriousSeldomUnlikely","SeriousFrequentPossible","SeriousFrequentUnlikely")>>

Determination of Required Performance Level (PLr)

Outcome of Test

The PLr for this machine is determined to be <<[Letter]>>. 

 

Severity of injury: <<[Severity of Injury]>>

Frequency: <<[Frequency]>>

Possibility of avoiding: <<[Possibility of Avoiding]>>



<<Start: SELECT(Machine[MachineID],[MachineID]=”4ab1fa65”)>>

<<SWITCH([_THISROW].[ImageSelect],

1, [MapImage1],

2, [MapImage2],

3, [MapImage3],

4, [MapImage4],

5, [MapImage5],

6, [MapImage6],

7, [MapImage7],

8, [MapImage8], 

""

)

>>

<<End>>




<<ENDIF>>

From which table do you trigger this Bot?

It's all run from table Machine.

I also tried the first statement with a >0 condition at the end like this:

 <<IF: IN([Counter],LIST("SlightSeldomPossible","SlightSeldomUnlikely","SlightFrequentPossible","SlightFrequentUnlikely","SeriousSeldomPossible","SeriousSeldomUnlikely","SeriousFrequentPossible","SeriousFrequentUnlikely")>0>>

but no joy.

I tried a much simpler test, I set up a field SubCounter which is either Yes or No.

The expression in the template was

<<IF: ([SubCounter])>>

....... stuff ....

<<EndIf>>

Looks like my earlier test wasn't valid, but I can't figure out why!

The [Counter] won't work if it's inside of the "PlrTEst" table. 

EDIT: table name fixed

Do you have a relationship between Machine and PlrTest table? For example like Ref column?

Oh sorry, I was using a different test table there.

I got it working in the  Machine table just by using a simpler test as above.

Thanks for trying to help me! I suspect the List-Counter test is more subtle than we think.

So..
#1 - What are your table names? I assume you have two of them.
#2 - From which table you are triggering the Bot
#3 - In which table you have the [Counter] column

Top Labels in this Space