I have created a quick BAQ and deployed it to show a list of part trans. I have added several parameters, each with the “skip condition if empty” checked.
If no parameters are entered, it crashes the query because it is trying to call every trx ever made in the history of ever.
How can I either
1.) Add a pop up message that reminds the user to enter at least one parameter
or
2.) Require at least one parameter to be entered before system runs the query
Side note - the parameter fields are far too long, I have played with the format to shorten them up, doesn’t seem to be doing me any good. Ideas on that?
I’m with @knash. In these situations, I don’t want to pull the entire table ever so I setup reasonable parameter defaults that have some sanity to them. I add a couple of calculated fields and use those as my params something like this:
--DataStartDate:
CASE
WHEN @StartDate IS NULL THEN convert(date, '2021-01-01', 112) -- Full years beginning with 2021 or use the year of your choice... This has a smaller return dataset than yours most likely.
WHEN @StartDate > Constants.Today THEN convert(date, '2021-01-01', 112) -- Full years beginning with 2021
ELSE convert(date, @StartDate, 112)
END
--DataEndDate:
CASE
WHEN @EndDate IS NULL THEN Constants.Today
ELSE @EndDate
END
-- Couple more for more ideas, and incase of strange OData params coming in :)
-- DataStartDate:
CASE
WHEN @StartDate IS NULL THEN datefromparts( year(Constants.Today)-1, month(Constants.Today), 1)
WHEN @StartDate = '' THEN datefromparts( year(Constants.Today)-1, month(Constants.Today), 1)
WHEN @StartDate > Constants.Today THEN datefromparts( year(Constants.Today)-1, month(Constants.Today), 1)
ELSE @StartDate
END
-- DataEndDate:
CASE
WHEN @EndDate IS NULL THEN Constants.Today
WHEN @EndDate = '' THEN Constants.Today
WHEN @StartDate > @EndDate THEN Constants.Today
ELSE @EndDate
END