Skip to content
+1-888-319-3663

EONE BLOG

Tech Tuesday: Restricting a SmartList Builder Report to the Previous Month


My user was creating a SmartList Builder report yesterday and asked me a question that had me initially stumped.

The goal was to run the report and restrict the data to the previous month – not the current month.

Figure 1: Simple SLB SmartList

For this, we will just report on the Purchase Order Work table and to make it easier to work with we’ll just select a few identifying fields – the Document Date in particular.

So of course – we go to the Restrictions window to add our restriction.

Figure 2: Begin/End of Month option

And notice immediately that while we have a options for “Month”, we only have Beginning of Month and End of Month which implies the current month.

So out of the box restrictions aren’t going to be helpful to make this work for us.

Now of course we could create a custom SQL view by hand to return the data and restrict it for us – but that wouldn’t be very interesting for this article. And a downside to this approach is that you end up with a custom view that is external to the SmartList Builder that you have to maintain.

So if we don’t have a restriction for BOM or EOM, what is Plan B?

Well, if we can write SQL to figure out if a given date is within the previous month, can we restrict by that?

And that is our answer – a calculated field.

In it, we use SQL to set a value of the calculated return to have it check our DOCDATE and then check to see if it is within our expected period. And if so, return a 1 – otherwise return 0.

Figure 3: Calculation

 

The text of the calculation is:

case
when
DOCDATE >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0)
and
DOCDATE <= DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1)
    then 1
    else 0
end

Now that we have the results of this so the calculation shows if it meets our criteria, we just need to create the Restriction.

Figure 4: Filter data with restriction

 

Now SLB will restrict the results of the calculation to 1 which would then be the records we expect to see.

Running the report in SLB – we see that indeed that the only data that displays is from the previous month.

Figure 5: Restricted data displayed

The Beginning of Month and End of Month restrictions that are out of box are using the GP User Date but it is worth noting that since we are pulling the data from SQL directly using GetDate(), the restriction is always going to be the date from SQL. Now ideally we’d be able to restrict by using the GP User Date instead because then I can change the report data by changing my User Date in Dynamics GP. However, since the User Date isn’t stored anywhere in SQL that I’m aware of and SLB doesn’t give us an option for “User Date” in the Special Fields, I don’t see a way to use that in any kind of calculation/restriction.

If I figure out a way to do this (without cheating and writing custom code in Extender Enterprise or VBA), I’ll update the article and sample to use that method.

Attached is the SmartList Builder report that I used from GP 2016.

Best always,

Patrick Roth
eOne

Leave a Comment





RECENT POSTS


2021 Q4 Promotions
Connect with us at Directions EMEA 2021 in Milan!
eOne at Summit North America 2021
Employee Spotlight: Megan Tripp, Business Development Representative
eOne is now compatible with Microsoft Dynamics GP October 2021 Release

POPULAR POSTS


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder

CATEGORIES

TAGS

Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships partners Popdock release Reporting SalesForce SalesForce.com SmartConnect SmartConnect.com SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.