Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Null Date Picker = "Object reference" error

Created: 10 Apr 2013 • Updated: 18 Apr 2013 | 18 comments
This issue has been solved. See solution.

I'm using date pickers in my workflow. If one of them is blank, and I leave the page, then return to the page; I get the symantec error page. The error from the log viewer is "object reference not set to an instance of an object"

Anyone know why this is happening? How can I prevent this error? I'd like the users to be able to blank out the date fields.

Thanks.

Operating Systems:

Comments 18 CommentsJump to latest comment

AnaMan's picture

Maybe you're using an output variable as initial value too?

Did you get the stack trace? It would be helpful.

reecardo's picture

Stack trace around this issue can be found in logs... <install>/Logs

Aryanos's picture

I don't think you can blank out the date or else you get the error you see. 

I like my beats fast and my bass down low

oshgosh's picture
AnaMan, I am using a dynamic model thing for the initial data, and I'm using the output variable in that model. I think that might be the problem. I'll take a look at it and let you know.
 
Here's the extremely helpful error from the log viewer:
 
System.Exception: Execution Exception ---> System.Exception: exception component created:  ---> LogicBase.Framework.BusinessRuleException: The critical error failed execution on component App Details : Object reference not set to an instance of an object. : at LogicBase.Components.FormBuilder.DatePickerComponentRenderer.PreRender() at LogicBase.Components.FormBuilder.Core.FormComponentRenderer`1.LogicBase.Components.FormBuilder.Core.IFormComponentRenderer.PreRender() at LogicBase.Components.FormBuilder.FormBuilderComponentRenderer.PreRender() at LogicBase.Core.Models.Dialog.ComposerForm.OnPreRender(EventArgs e)
   --- End of inner exception stack trace ---
   at LogicBase.Core.ExecutionEngine.ExceptionComponentDelegate.Execute(IData data, IOrchestrationComponent comp, String& outputPath, IExecutionEngine engine, TLExecutionContext context)
   --- End of inner exception stack trace ---
   at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunEngine(List`1 executionQueue)
AnaMan's picture

Judging form the stacktrace - the three properties cannot have a null value in this execution step: Min Date, Max Date and date set to a form control.

A form control date is set by an initial date. So you can be right - if you are using the output variable in the initial value model you have to protect this model from returnig a null value as a result.

How are you setting the minimum and maximum dates? Are you using the constants or other value source?In the latter case is possible you provide a null value to Min or Max Date property.

AnaMan's picture

So as I said - if you are using dynamic model for initial value prevent it from returning a null value. You can use an Variable Exists Rule component and, in case of false, return for instance a today date.

oshgosh's picture

Tried it, still no luck. I even wiped the dynamic model and set the initial date to "Start Today" and still got the same error.

This doesn't make any sense.....

HarrisT's picture

I just figured out there is a defect with the DatePicker and DateTimePicker components.

I have created a KB article for this, KB article TECH205198. This article will not be public until tomorrow.

The problem with these components is this:
The components will automatically initialize the default values to be the values of the Output data, even though you tell the component to use a different variable as the default.

I believe you're experiencing the "Object reference not set to an instance of an object" when you don't provide a value to this because it won't accept a NULL value.
 

What I would suggest as a Workaround would be to put a check in your Workflow before entering the form. With this check, ensure the Output variable exists, and is set to the value you would like the form to default the date/time to.

Hope this helps!

reecardo's picture

As an aside... DateTime is a value type in C#, like an int; it can't have a null value. A nullable datetime i.e. DateTime? yes, but not a datetime.

oshgosh's picture

Oh wow. Thank you.

What is a KB article? Is it like a bug fix request?

I'll try this workaround suggestion.

reecardo's picture

KB = Knowledge Base, so a Knowledge Base article.

oshgosh's picture

I did the workaround. It's not quite working.

I have a variable exists component before the form that checks the date. If the output data doesn't exist, it sets it equal to today, then goes back to the form with the date picker on it.

This actually works the first time the workflow goes down this path. But if I set the date to null again and go down the same workflow path, I get the same error, but it fails right at the "Variable Exist" component, not at the form. 

This whole thing is blowing my mind....

HarrisT's picture

The variable actually does exist, it just can't be NULL. Perhaps on your way back into the Form add a Remove Data component, removing the datetime variable before you re-enter the form.

Which version of Workflow are you using?

HarrisT's picture

After doing some testing, I am able to reproduce this. If you ever set that date to NULL, you will be unable to use the form again without throwing an exception. This happens even if you try to remove the variable, or set it to something other than NULL later.

I could not find a workaround for this other than not using a NULL value for the date, c# does not allow this and Workflow is run using c#.

SOLUTION