HPE Morpheus Enterprise
1828430 Members
3436 Online
109977 Solutions
New Discussion

Re: Assistance with If/Else Conditional Workflow

 
SOLVED
Go to solution
Not applicable

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.

14 REPLIES 14
Not applicable

Re: Assistance with If/Else Conditional Workflow

@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!

Ibrahim-GCC
Advisor

Re: Assistance with If/Else Conditional Workflow

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.

Not applicable

Re: Assistance with If/Else Conditional Workflow

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!

tyboyd
Trusted Contributor

Re: Assistance with If/Else Conditional Workflow

I updated my old post to reflect.

tyboyd
Trusted Contributor

Re: Assistance with If/Else Conditional Workflow

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.

Not applicable

Re: Assistance with If/Else Conditional Workflow

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!

Not applicable

Re: Assistance with If/Else Conditional Workflow

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

tyboyd
Trusted Contributor

Re: Assistance with If/Else Conditional Workflow

Can you try

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

Re: Assistance with If/Else Conditional Workflow

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

Not applicable

Re: Assistance with If/Else Conditional Workflow

@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?

tyboyd
Trusted Contributor

Re: Assistance with If/Else Conditional Workflow

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

Not applicable

Re: Assistance with If/Else Conditional Workflow

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!

Not applicable

Re: Assistance with If/Else Conditional Workflow

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

tyboyd
Trusted Contributor
Solution

Re: Assistance with If/Else Conditional Workflow

Could also do

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