I am trying to compare two dates and then choose the lower of the two dates in a BPM. One date is in a UD table and one is entered by a user, so will be in BPMData.Date03. I have tried putting this in a Condition and a Set Argument/Variable, but nothing seems to work for me.
When I try to do it simply and just compare the dates, I get the error message “BPM007: Result of expression cannot be compared with variable of ‘System.DateTime?’ type”.
I have tried converting the dates to Integers or Decimals, through an “If, then” statement like below and then have the result be the date field I want, but get the error message “error BPM006: Result of expression cannot be assigned to variable of ‘System.DateTime?’ type”.
I don’t think it should be as hard as you are making it. I think you might have something more simple set up wrong. Can you show some screen shots of your BPM?
Converting a date to a decimal is not going to work. I would recommend get some basics in before you tackle any of this if you admittedly don’t know C# lots of resources online here is one to get you started if you want to spend some money Team Treehouse is awesome!
I am able to save within the design view, but when I get back out to the Method Directives screen and hit save, I get the “error BPM006: Result of expression cannot be assigned to variable of ‘System.DateTime?’ type” error.
Because you are using nullable object types you are going to need to do some casting and conversions to different types to get it done. Under normal circumstances you should be able to directly compare dates, but the nullable types play by different rules at runtime.
Perhaps you could shed some extra light on this? I am running into this issue now.
I’m confused about how a datetime can be nullable and what exactly I am supposed to do, to convert it. As far as the bit of research i have done there is no conversion tool to just make something non-nullable.
The link jose posted above should explain what it is and how to work with it. Most any type, when typed as such, can contain a null value DateTime?, Boolean?, etc
I was very confused how to implement the above article within expression editor. However it did help me further google my issue. Which lead me to the always helpful stack overflow. Ended up being able to just use Convert.ToDateTime() to solve this problem.
As an aside we try to avoid BpmFuncs and use their real C# counterparts when doing a custom expression. I can’t remember exact cases of when or why but we have had those mess us up a few times and the ‘real’ C# versions worked better without the EpiMagic.