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
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Sunday, August 22, 2010
Posts: 11, Visits: 43
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
Senior Member

Senior MemberSenior MemberSenior MemberSenior MemberSenior MemberSenior MemberSenior MemberSenior Member

Group: Forum Members
Last Login: Friday, January 16, 2009
Posts: 8, Visits: 21
 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 (499 views, 296.95 KB)
NullVariable.zip (467 views, 1.88 KB)

Post #761
Posted Friday, May 09, 2008
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Sunday, August 22, 2010
Posts: 11, Visits: 43
Thanks. That worked fine.

The expression can be simplified from:

(Variable.MyVariable == null) ? true:false
to
Variable.MyVariable == null
Post #764
Posted Friday, October 30, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Monday, November 21, 2011
Posts: 11, Visits: 66
Hi

I'd like to raise an issue with this scenario,I have tried this solution in BPM.NET 2006 and it works fine, however, when using a task based variable, it does not work, e.g.

(Variable.^UI-SingleTaskRespondingUser==null)?true:false

On clicking OK, the following error appears:

c:\WINDOWS\Temp\_l173fja.0.cs(11,9) : error CS1525: Invalid expression term '=='
 
c:\WINDOWS\Temp\_l173fja.0.cs(11,11) : error CS1026: ) expected
 
c:\WINDOWS\Temp\_l173fja.0.cs(11,15) : error CS1002: ; expected
 
c:\WINDOWS\Temp\_l173fja.0.cs(11,15) : error CS1525: Invalid expression term ')'

Code generated is:

using System;
using System.Text;
using Workflow.NET;
namespace Samplenamespacec161bc3071584a52b349f3e4c14100fa
{
public class Sampleb508fd62ffdd42d397030bdaa6fe35df
{

public object SampleMethodbff44cf2a4b7434db7c9960282fd0b41(Workflow.NET.Engine.Context _context)
{
return (==null)?true:false ;
}

}
}

In the code it is dropping the variable, should this work?

Thanks

Jon

Post #1658
Posted Friday, October 30, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Thursday, February 10, 2011
Posts: 28, Visits: 47

Hi Jon,

You may try using the individual property of the respective variable as mentioned below

Variables.^CandidateApprovalRespondingUser.UserName==null?true:false

This should work.

Regards

Saravanan

 

Post #1665
Posted Wednesday, November 04, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Monday, November 21, 2011
Posts: 11, Visits: 66
Hi Saravanan
 
Thanks for your response, this allowed me to set up the decision task, however, the workflow always finishes at the decision task with no output, so if I check for Null and if it is the output should be NULL, else NOTNULL, but neither output is generated, it just stops. The error logged is as below.
 
Cheers
Jon
 
i - @#@Date - 14:58:21.984@#@Module - C:\WINDOWS\assembly\GAC_MSIL\Workflow.NET.NET2\3.0.0.0__00d117614105018c\Workflow.NET.NET2.dll@#@FileName - Context.cs@#@_MachineName - gblontvm02, Process - WFEngine.NET2@#@Message - Completed - Action Start for ExecutionID=67 ExecutionDetailsID=562 Exiting with Output=@#@
i - @#@Date - 14:58:22.0@#@Module - C:\WINDOWS\assembly\GAC_MSIL\Workflow.NET.NET2\3.0.0.0__00d117614105018c\Workflow.NET.NET2.dll@#@_MachineName - gblontvm02, Process -
WFEngine.NET2@#@Message - **** Error while executing GetProcessedValue : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Workflow.NET.DynamicCode.WorkflowDecisione64b7ef0eb7e41a0a9197eca9677d610.Methodb2390330c40741c5b63e750d0178cad0(Context _context)
   at Workflow.NET.DynamicCode.WorkflowDecisione64b7ef0eb7e41a0a9197eca9677d610.GetProcessedValue(Context _context)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Workflow.NET.PropertyTypes.PropertyDecision.GetProcessedValue(Context _context)@#@
i - @#@Date - 14:58:22.0@#@Module - C:\WINDOWS\TEMP\Skelta2006Temp\WorkflowElements\Faraday\ShadowTempFaraday\assembly\dl3\b36a7c14\00c4b3cc_fb9fc801\Workflow.NET.ActionHandler.NET2.DLL@#@FileName -
Context.cs@#@_MachineName - gblontvm02, Process - WFEngine.NET2@#@Message - Output after evaluating the expression for action Decision1 :  ExecutionId:67 ExecutionDetailsId:563@#@
i - @#@Date - 14:58:22.0@#@Module - C:\WINDOWS\TEMP\Skelta2006Temp\WorkflowElements\Faraday\ShadowTempFaraday\assembly\dl3\b36a7c14\00c4b3cc_fb9fc801\Workflow.NET.ActionHandler.NET2.DLL@#@FileName -
Context.cs@#@_MachineName - gblontvm02, Process - WFEngine.NET2@#@Message - Persist Actioin log Messages Completed. ExecutionId:67 ExecutionDetailsId:563@#@
Post #1671
Posted Wednesday, November 04, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Thursday, February 10, 2011
Posts: 28, Visits: 47

Hi Jon,

You might get the exception "Error while executing GetProcessedValue" if the variable which you have used within the workflow contains NULL and trying to compare/route the decision activity. If the variable contains NULL there will not be any output from the decision activity. Ensure that variable has an appropriate value so that the workflow proceeds further with the next step following the decision activity and also executes successfully.

 

 

Post #1672
Posted Thursday, November 05, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Monday, November 21, 2011
Posts: 11, Visits: 66
Hi Saravanan

But this was the point of the expression, to check whether the Variable is Null. I cannot set the value of this to a default value as it is a derived variable associated with the Task completion, i.e. one of your ^ variables, which you cannot populate with a SetVariable action.

Is there no way of checking this within workflow, without writing code?

Cheers

Jon

Post #1673
Posted Thursday, November 05, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 9:21 PM
Posts: 17, Visits: 42
If the variable contains NULL , Decision Activity does not provide any output,there is no option to check this in the workflow. However, this is taken care in BPM.NET 2009.

-Suman.

           

csn

Post #1674
Posted Friday, November 06, 2009
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Monday, November 21, 2011
Posts: 11, Visits: 66
Thanks Suman, I will have to deal with this another way.

Cheers

Jon

Post #1675
« 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 4:54am

 
Execution: 0.219.11 queries.Compression Enabled.

Copyright © 2002 - 2009 Skelta Software. All rights reserved. Tel: 1 (678) 306 4110 | Email:sales@skelta.com
Skelta - A BPM Workflow Software Company