www.skelta.com
Home      Members   Calendar   Who's On

Welcome Guest ( Login | Register )
      

Home » BPM.NET 2007/Sharepoint Accelerator 2007 » BPM.NET 2007/Sharepoint Accelerator 2007 » Application Development » Decisions and null variables


Decisions and null variablesExpand / Collapse
Author
Message
Posted Wednesday, April 30, 2008
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Monday, May 26, 2008
Posts: 2, Visits: 9
I'd like to use decision action based on the existence of a Workflow instance variable. If I add a rule like "Variable.MyVariableName Contains Data", I get an error that looks like:

**** Error while executing GetProcessedValue : System.Reflection.TargetInvocationException:
System.NullReferenceException:

Looking at the generated code, it uses:
_context.Variables["MyVariableName"].Value

which would cause a NullReferenceException if _context.Variables["MyVariableName"] is null. Is there another way to determine if MyVariableName is null?

Thanks
Post #759
Posted Tuesday, May 06, 2008
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: Thursday, May 22, 2008
Posts: 6, Visits: 18
 Hi Tonyyng,

You can use Expression Editor in Decision action to  determine whether the variable (MyVariableName) is null or not. Use the below sample code in Decision action's Expression editor. Find attached the document (DecisionAction.doc) as well as the workflow xml (NullVariable.zip) for your referecce.

(Variable.MyVar == null) ? true: false

ReturnType+= Sysetm.Boolean

 

 

Let us know the status after performing this.

Regards,

Anil

  Post Attachments 
DecisionAction.doc (53 views, 296.95 KB)
NullVariable.zip (41 views, 1.88 KB)

Post #761
Posted Friday, May 09, 2008
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Monday, May 26, 2008
Posts: 2, Visits: 9
Thanks. That worked fine.

The expression can be simplified from:

(Variable.MyVariable == null) ? true:false
to
Variable.MyVariable == null
Post #764
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
-
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.

All times are GMT -5:00, Time now is 3:45am

 
Execution: 0.094.11 queries.Compression Enabled.

Copyright © 2002 - 2007 Skelta Software. All rights reserved. Tel: 1 (703) 229-6732 | Email:sales@skelta.com
Skelta - A BPM Workflow Software Company