Solved

K2 Five Split Boolean Check Against NULL

  • 11 October 2018
  • 3 replies
  • 123 views

Badge +4

I've been at this a while now, I'm reading a boolean colulmn from a list of records. With that, not all the records have a value, thus some contain "NULL" during a looping process. Items without a value are to be orphaned and pushed back into the prior task to again be addressed.

 

Within the Split Rule I've attempted the following:

 

IF (Bool != scnull (Plain text)) THEN...

----

IF (ToString(Bool) = Empty String (text) THEN...

----

IF (Bool = True (True/False) OR Bool = False (True/False))

THEN IF (Bool = True(True/False)) THEN Approve (Path) ELSE Deny (Path)  ELSE Orphan (Path) 

----

IF (Length(ToString(Bool)) >= 0)

THEN IF (Bool = True(True/False)) THEN Approve (Path) ELSE Deny (Path)  ELSE Orphan (Path) 

 

A Few others, but in the end whenever I compare my Boolean against a "NULL" I get either:

 

String was not recognized as a valid Boolean

OR 

Unable to compare values that are not of the same type 

 

Any suggestions?

 

I also though of creating a reference before hand and filtering out thos items in the Split, but then again those inital items would need to be Split with the same type of logic.

 

In K2 4.7 the Filter Operations contained an "IS NULL & IS NOT NULL" value.

 

Essentially I'm recreating a workflow in the new version of an existing working process.

 

Thanks,

icon

Best answer by alexhaberer 19 October 2018, 16:00

View original

3 replies

Hi Alex,

 

I'm new too... and have been working through split step logic most of the day.  

 

That said, any chance you tried to use the "Match" regular expression (

https://help.k2.com/onlinehelp/k2five/userguide/5.1/default.htm#K2-Workflow-Designer/Use/ContextBrowser/Functions/Functions.htm).  Was thinking perhaps you could somehow structure logic similar to example 4 using the smartobject list/record as the input and looking for a NULL pattern (which I suspect would be "")?

 

Thinking that if you had an IF (Match for Null pattern) = true condition to start it off, you could then direct things with Nulls one way and those without a second way.

 

Just a thought... though I'm new here myself, so maybe you've already tried this.

 

Good luck!

 

Badge +4

So I couldn't figure out a good way to do this with their expressions/logic and not being able to check a boolean against a null value without a comparison exception/error.

 

To complete what I was looking to accomplish I created end up creating a "Data Field" of the boolean column I was testing against.  The data field converted the boolean column to a string (Which "ToString(Boolean)(text)" could not do.) and I then used that data field to compare within the "SPLIT" condition.

 

Set Data Field:

Field Name = NULL Check

Value = Boolean 

 

IF (NULL Check = Empty String (text) ) {

    Orphaned

} ELSE {

    IF(Boolean = True(true/false)) {

        Approved

    } ELSE {

        Denied

    }

}

 

Overall after trying multiple things I was finally able to do this, I can't be sure this is the best way, but the only way I have seen without having to change the database type or doing something like adding in another bit or column to then test against.

Badge +4

Sorry messed up this was an ELSE IF as seen here:

 

IF (NULL Check = Empty String (text) ) {

    Orphaned

} ELSE IF (Boolean = True(true/false)) {

   Approved

} ELSE {

   Denied

}

}

Reply