BAQ newbie question - constants and variables

OK, maybe I’m not that new to BAQs. But I feel silly to have never asked this.

Is there not a way to declare a variable or constant in a BAQ?

Yes, I use parameters, but it prompts the user. I don’t need that.

The most ideal use case would be to grab a value from a table, store it as a variable, and then reference that instead of querying the table thousands of times.

Here’s a simple example of this. To grab some data from PartDtl, I want to exclude forecast data per the company configuration settings (+X days and -Y days). The way I do this is to join on JCSyst (Company = Company) and then filter PartDtl per those settings. (Or I could have put that in the join itself.)

But all I really needed to know is that it’s +30 and -0 (or whatever).

But even for something simpler than this, like a truly static value that I use in 5 places in a BAQ, like [today - 30 days], I might want to make that [today - 60 days] and now I have to find the 5 places I set that value. Sometimes I do that repeatedly to test something.

I’ve done this via a subquery and a calculated field, then just join in the subquery (doesn’t need to be a complex one) on company or something and display the calculated field which outputs your constant.


Like a subquery on Company (for the current company) - thus having only 1 record - and then a totally bogus calculated field for the sole purpose of being a constant.

Neat - I hadn’t actually bothered to try that before. That’s going in the memory banks.

But this means you are saying there is indeed no simple way to just set a constant of ThisNumber = 7. Right?

Not to my knowledge, but I bet you could via the use of the “run BPM designer” too to set global execution level variables. I like the subquery approach since it’s easy to maintain your global variables in 1 subquery and those apply wherever you want

This is what I do as well, should work well for Mr. Low Code @JasonMcD

You could also link to UserCodes or SysTag. Define your variables there.
Pretty flexible.

For sure. But still a lot of extra steps.

I smell an Epicor Idea brewing.

Wow if that isn’t a setup for a dumpster fire. @josecgomez

Look up 1 post

I do like all the alternate ideas, don’t get me wrong. I’ve put a total of zero effort into this problem before, so I appreciate the advice. Lots of tools for different uses.

But does it not strike anyone as a tad absurd that you can’t have a non-prompting parameter, basically?

Your subquery can contain only calc fields.


1 Like

I was going to add a #dumpster-fire tag to this thread, but apparently I can’t go past 10 characters? Oh well.

You don’t even need to bring a table. Just make a calculated field, fill in a value, and you will get one row.


1 Like

I meant to test if that’s what @klincecum was meaning earlier.

No kidding. I did not know that. It makes no sense to me, so I never tried it.

Very nice. Seems like the least bloated option.

1 Like

Then you can do this.


(I changed the variable to a valid part number)


@Banderson What am I looking at in this post? Is there a subquery I am not seeing?

I just used a single level for an example, but no reason you couldn’t make it a subquery. Or even just leave the calculated field in your top level. You’ll just have an extra column. You can ignore that.

Oh, OK. But you can’t now call that variable* in 4 other subqueries, right?

*I know, it’s not really a variable

You might have to play with the syntax, but you should be able to. If you are using it in different levels, you might have to do level.field to get it to work.

Worst case, you just drop the sub query into whatever level you need it. Then it should be available. (you don’t need to join it)

1 Like

Mmm, ok. I learned not to do that long ago with real tables.

  • If you have table/subquery A with 5 rows,
  • And you add in table B with 3 rows
  • And you do not join table B to anything
  • Result set now has 15 rows

Of course, I usually make that mistake with tables that have thousands of rows. Oh what fun that is.

But I guess if the MyVariable subquery has 1 row, then Z x 1 = Z

So I guess that’s why it’s OK?