How do i use if else while having a word

studio

#1

I have used get OCR text to get a keyword. The keyword can only be one of two words. I created an If activity for the workflow, if its keyword 1 do this, else do that. However, it only runs the else part…


#2

@CalvinW May be ur extracted text not getting required word to execute then part of if condition. Try to print extracted text to check to what value u getting.

Otherwise in if condition u may be using = , it will will match only exact value on right hand side value, instead of = use contains method of string it can match the extracted text if it contains the string in if condition.


#3

I tried using message box, it works.

Can you give an example?


#4

@CalvinW

extractedtextVariable.Contains(“Urword”)

This method return true if extrcated text has urword in it, returns true, then part of if condition is executed.


#5

My IF gives me this error

RPA Inventory valuation has thrown an exception

Source: If

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


#6

This error usually occurs when you declare a variable and didn’t initialize any value for it.


#7

I dont think its a variable with uninitialized value, it was working fine before


#8

@CalvinW can you attach your workflow