Assistance with If/Else Conditional Workflow

Hello!

I’m poking at the If/Else Conditional Workflow type task but I keep hitting an error around:

Cannot convert null value ‘undefined’(language: JavaScript, type: undefined) to Java type ‘boolean’ using Value.asBoolean(). You can ensure that the operation is supported using Value.isBoolean().

No matter what I try. I’m sure I’m missing something simple.

I have a task with a really simple Powershell array that gets converted to JSON and ‘write-output’:

$RESULTSOUTPUT = @{}
$RESULTSOUTPUT.add("Unzipping Results", "Success")
$RESULTSOUTPUT.add("MECM Innstallation", "Success")
$RESULTSOUTPUT.add("Success", "True")
Write-Output($RESULTSOUTPUT | ConvertTo-Json)
Exit 0

This is set to be registered to Code “MECMsuccess” with Result Type JSON

I then have a debug task that just does write-output(“<%=results.MECMsuccess.Success%>”)
and that spits out True as expected

The next step is the If/Else Conditional Workflow task, which I setup with information from Looking guidances for triggering multiple automation tasks based on user inputs Yes/No in service catalog - #2 by Tyler_Boyd as my example:

if (results.MECMsuccess.Success == “true”) {
true;
} else if (results.MECMsuccess.Success == “false”) {
false;
}

(I also tried using three ==='s as the text block has two but if you click to expand the screenshot you can see there are three there).

The results I get no matter what are:

Error Executing Conditional Workflow Task _Catalog - MECM Email Logic - Cannot convert null value 'undefined'(language: JavaScript, type: undefined) to Java type 'boolean' using Value.asBoolean(). You can ensure that the operation is supported using Value.isBoolean().

This holds true even if I adjust things to just be a Single value result or a Key/Value. I’m not sure what in the Boolean is going on.

Can you try

if (results.MECMsuccess.Success == "True") {
    return true;
} else if (results.MECMsuccess.Success == "False") {
    return false;
}

Could also do

if (results.MECMsuccess.Success == "True") {
    return true;
} else {
    return false;
}

Tyler,

If it’s because I didn’t catch the capitalization of the “True” and not having a general else instead of else if… haha.

I’ll test that here and post back. Thank you!

Tyler,

That did it! It looks like the missing ‘return’ is what was throwing things off as the error went away and the task worked successfully on adding the “Return”

Thanks!

– Ron

1 Like

I updated my old post to reflect.

1 Like

Sorry to be a pain, but I think it almost worked.

If you look, that seems to have triggered the “Email on MECM Installation success” task, but the logic in the If/Else is

It seems the false didn’t run the fail workflow and associated task but still ran the true/success workflow and task

Interesting, I’m not seeing the same thing.

What version of Morpheus are you on? The same logic is working for me in 7.0.5.

We’re on version 7.0.4

Being my first time playing around with this stuff, it couldn’t just be something I have screwed up or am doing wrong and that wouldn’t surprise me

I’m updating this test instance to 7.0.5 and will give it another go after that completes. Thanks!

I’m hitting the same in 7.0.5 where both success and fail seem to kick off the “Success” email workflow and not the “Failure” email workflow.

I might create another variant from scratch and see if that works and why typo or something I may have in the original.

Thanks!

If it continues to be an issue you may want to look at putting in a ticket in case you are hitting a bug.

I utilized the conditionals within this package for the approvals check:
Package
Repository

@Tyler_Boyd @cbunge Thank you for the replies and information.

I did rebuild just a really simple workflow using the Conditional and it worked there, so I must have something boogered up in my original attempt I’ll have to flush out.

Thanks!

2 Likes

I need few more input on passing the values in JS.
results.MECMsuccess.Success here MECMsuccess is the taskcode?

if yes, I am using the same but getting the below error. It will be great if we have some small examples and recoding’s.

@ibrahim
In my case, yup the MECMsuccess was the task code output variable from my test script. Not sure on your error as that seems to maybe indicate the wrong type of task vs what’s allowed?

1 Like