Null values and date formats part 2
This issue in this post (https://support.geocortex.com/essentialsGSCForum?sub-nav=forum&main-nav=essentials&#!/feedtype=SINGLE_QUESTION_DETAIL&criteria=ALLQUESTIONS&id=9066000000008ieAAA) is exactly what I'm going through but unfortunately the link posted by Jonathon from Latitude isn't working. Does anyone either know the workaround he mentions or how to find that post?
0
-
Hi Emily,
Unfortunately, our forum software was updated and all older posts were orphaned. I can see the post you are referring to in our old system still, here is the answer that was posted -
----------------->
The problem appears to be that all elements are evaluated whether or not they are actually used, and calling a string method on System.DBNull.Value produces an error.
You should be able to get around this by using the following ugly hack:
(SITUS_CITY == System.DBNull.Value ? "" : (SITUS_CITY + " ").ToString().Trim())
This will ensure that the expression will always evaluate to a string, and thus the operation will always be valid.
<-----------------
I hope this helps, it's quite old!
Regards,
Wayne Richard
Latitude Geographics Group Ltd.
Head Office: 300 – 1117 Wharf Street Victoria, BC Canada V8W 1T7
Tel: (250) 381-8130 | Fax: (250) 381-8132 | wrichard@latitudegeo.com
Developers of Geocortex web-based mapping software | www.geocortex.com
An Esri Platinum Business Partner0 -
Thanks for the response, I'll give it a shot! 0 -
Hey Wayne, sorry about the late response
This code does work when the date value is null (it leaves a blank space on the report), but when there is a value I get this:
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XeJP&feoid=Body&refid=0EMf2000000YDhP"_/_img_
Here's how I have it set up in the report:
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XeJP&feoid=Body&refid=0EMf2000000YDhZ" _/_img_
Anything stand out as being incorrect? Thanks again!0 -
Hi Emily,
I have asked the original author of the workaround to comment.
Regards,
Wayne0 -
Hi,
It has been a while, but I think the original code was assuming a string field. If the object is a Date, then it is invalid to concatentate a space with it. Try removing the + " " and see how that works:
(RepairBy == System.DBNull.Value ? "" : RepairBy.ToString())0 -
Darn, now it's the other way around. When the RepairBy field has a value, it shows up, but I get an error in the report when it's empty. It sounds like System.DBNull.Value is the right way to go, I just need to fiddle with it so it works with both cases. Thanks! 0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
6 kommentarer