BPM C# Code Date Difference - for reference

Just putting this into the forum as there wasn’t anything I could find the help with this.

Application - We are looking to go live with Epicor shortly. Our current processes allow for too many issues / invalid data to be created. We are looking to let loose buyers with PO Suggestions but the risk is they get too fixated on the select all, buy all process without checking if the Suggestion is valid and that we have to buy now. I have created a BPM to remove rows when searching for when the date is too far out. Was getting stuck on C# code to work that out but here’s where I ended:

ttSugPoDtl.RemoveAll(ttSugPoDtl_Row => ttSugPoDtl_Row.OrderByDate >= DateTime.Now.Date.AddDays(14));  

NOTE 14 days is calendar, not working as per rest of Epicor.

If you are looking for this query to use the SHOP calendar, then you will be disappointed. There is nothing in the system that will allow you to have a query that uses anything other than real calendar dates. The shop calendar is only used by the Scheduling system to schedule jobs, and by the purchasing system to schedule the POs.

Hi Tim,

Thanks for the feedback

This is only used to reduce the buyers from going overboard with PO suggestions. I wasn’t looking to use elsewhere but just thought I should post as I thought it should be easy thing to work out. Once we’ve seen how things go with the buyer I could remove.



Hi @Matt_Belshaw

Your code for date comparison is correct, and it should work if you put it under the correct Method Directive.

I’m not sure where exactly you are trying to remove PO Suggestions? Which screen? Which action?
Tracing Options can help you to find out the exact Method Directive to use for BPM.

Assuming it is “Erp.POSugg.GetList”,
Your code should look like the below, under a Post-Processing directive:

ttSugPoDtlList.RemoveAll(row=> row.OrderByDate >= DateTime.Now.Date.AddDays(14));

Hi Ibrahim,

The code does work I just posted as it took me a long time to get there for something I thought should be simple and others could benefit.

You’re assumptions are 100%. We will be new to PO suggestions so I am trying to reduce the risk of buyers getting click happy!


@Matt_Belshaw I have mine like this on GetRowsPlant and I also color code with row rules to guide the buyers to suggestions that are date changes and not new purchases.

Hi Greg,

Just curious ow can you tell in PO suggestions if the date has changed?


How you know a suggestion is a change depends on if you lock quantity and dates. We lock them both so we will never get a change suggestion, so I check demand vs on order and if have more on order than demand then it is a change. If you don’t lock then you will get a change suggestion and it will have a suggestion code of either X for Expedite or P for postpone, but those are loaded as change and not new suggestions from the buyer workbench.