One formula making another fail!?

I had a formula working well… (It creates a header at the top my roster. It generally reads…
**Seating List 26-27

Tuesday – K

Lead: Smith

"Music Seating List 26-27" + cr() + <size:5>"+cr()+"" +
lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "LongDay", "") + " — " +
lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "Grade", "") + cr() + "<size:5>"+cr()+"" +
"Music Lead: " + fieldvalue("Class Heading Information",MusicLeadLast)+"
"

but this formula, below, upon adding it to a different Text Display Object, makes the first formula fail (in that all the variables/fields don’t display, except MusicLeadLast, which I believe is from the “second teacher’s” record…but I need to be from the primary teacher’s record. Only the text strings display.). And it only happens when there is no “second teacher” in the formula below. It generally reads…

Jones
(Allen)

but it fails when it reads…
Jones
() ← notice the “second teacher” is blank; that’s intentional; I’ll eventually hid the parentheses as well. It’s when this “second teacher” is blank, that the formula above fails.

""+gClHdgInfoDB_Teacher+""
+cr()+"("+""+
superlookup("Class Heading Information",
{PeriodDayCombo=lookup("Class Heading Information", "Teacher", gClHdgInfoDB_Teacher, "PeriodDayCombo", "") and Teacher<>gClHdgInfoDB_Teacher},
{Teacher},
"default","")+"
"+")"

I previously wrote that I fixed it. I haven’t. In the formula at the top, MusicLeadLast field is displaying but I think it’s reading from the second teacher’s record. LongDay and Grade are still not displaying.

Note: I think a few bold tags got pulled off when I pasted the code here.

I feel like I’m not making myself very clear here. I will try to come back and make this clearer.

upon adding it to a different Text Display Object, makes the first formula fail

I think you are saying that you believe that adding a second Text Display object is making the first Text Display object fail?

If I am understanding you correctly, I can assure you that this is not what is happening. Every Text Display object is independent. It’s not possible for one Text Display object to affect another one. (Before Dave mentions it, there actually is a way for this to happen, if you used the assign( function in the formula. That could allow an interaction (called a “side effect”) between separate formulas. But there is no assign( function in your formulas, so that isn’t happening.)

Based on the information you have provided, I have no idea what is going wrong. I do agree that your statement of the problem isn’t really very clear, hopefully you can clarify. But I am absolutely sure that the Text Display objects aren’t affecting each other. Most likely there is some third outside factor that is causing the problem.

In a separate post I mentioned that global variables should be avoided. If you somehow managed to create two gClHdgInfoDB_Teacher variables, one a fileglobal and one a global, that could cause the type of problem you are seeing. Is there a Text Editor that is connected to the gClHdgInfoDB_Teacher variable? If so, that would create a fileglobal variable, which would conflict with the global variable you have set up. I would strongly urge you to consider eliminating the use of global variables. I realize that adds extra complications, but it also eliminates the possibility of hidden scope conflicts (fileglobal vs. global scope) that can be super difficult to track down.

notice the “second teacher” is blank; that’s intentional; I’ll eventually hid the parentheses as well.

When you get around to “eventually”, check out the sandwich( function. Using this function will make it trivial to hide the parentheses when they are not needed.

1 Like