SO Line Scheduled Date  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

SO Line Scheduled Date

Postby pricerc » Thu Sep 24, 2020 9:36 am

Customer asks: "Can we make it default to null?"

They would like to repurpose it as an expiry date.

Me: can't even change it to null - if I clear the editor, it defaults back to today's date as soon as I tab away. It seems the best I can do is make it something like 1/1/1900.

I can't find code that's changing ScheduledDate in any plugins.

Is this possible, or would we need to go down the custom field route?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: SO Line Scheduled Date  Topic is solved

Postby Scott.Pearce » Thu Sep 24, 2020 10:43 am

The SalesOrderLine.ScheduledDate property is a Date type. The Date type is a value-type and therefore cannot be set to NULL. Normally when dealing with the Date type, in programming circles, DateTime.MinValue is used to denote NULL or "no date". Sadly Jiwa does some silly things with the saving of SalesOrderLine.ScheduledDate when it is set to DateTime.MinValue (Jiwa saves NULL to the database) and with the reading of SalesOrderLine.ScheduledDate (if null then use Today). This behaviour thwarts my attempts to use the DateTime.MinValue-as-NULL technique.

HOWEVER, in a similar vein to the aforementioned strategy, I have instead leveraged DateTime.MaxValue and jumped through a hoop or two to achieve what you want. Best to look at the plugin for an understanding. In a nutshell, we are using a special known date value, and when we come across said value during display, we set the cell.Value to NULL, which gives a blank cell. Note that reports, etc. must be made intelligent enough to know about the special known date value in SO_Lines.ScheduledDate (in this case DateTime.MaxValue) and treat it accordingly.

Plugin SO Line Scheduled Date NULL by default.xml
(36.66 KiB) Downloaded 24 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: SO Line Scheduled Date

Postby pricerc » Thu Sep 24, 2020 12:27 pm

Scott.Pearce wrote:The SalesOrderLine.ScheduledDate property is a Date type. The Date type is a value-type and therefore cannot be set to NULL. Normally when dealing with the Date type, in programming circles, DateTime.MinValue is used to denote NULL or "no date". Sadly Jiwa does some silly things with the saving of SalesOrderLine.ScheduledDate when it is set to DateTime.MinValue (Jiwa saves NULL to the database) and with the reading of SalesOrderLine.ScheduledDate (if null then use Today). This behaviour thwarts my attempts to use the DateTime.MinValue-as-NULL technique.

HOWEVER, in a similar vein to the aforementioned strategy, I have instead leveraged DateTime.MaxValue and jumped through a hoop or two to achieve what you want. Best to look at the plugin for an understanding. In a nutshell, we are using a special known date value, and when we come across said value during display, we set the cell.Value to NULL, which gives a blank cell. Note that reports, etc. must be made intelligent enough to know about the special known date value in SO_Lines.ScheduledDate (in this case DateTime.MaxValue) and treat it accordingly.

Plugin SO Line Scheduled Date NULL by default.xml



Thanks Scott, I'll take a look.

I know it's a date type, but I also noticed that the field in SQL is nullable, and that there is logic in Jiwa that maps NULL SQL dates to datetime.minvalue, so I was kinda hoping there was something I'd missed.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: SO Line Scheduled Date

Postby Scott.Pearce » Thu Sep 24, 2020 12:31 pm

and that there is logic in Jiwa that maps NULL SQL dates to datetime.minvalue


Yep, and if only we mapped back the other way when we read the line! When reading a line we initialise ScheduledDate to Today(), and then only set it if the database value is NOT NULL. The net effect being that NULL values get read in as the current date. :-(
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron