cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

200
Views
10
Helpful
5
Replies
Beginner

set a task result based on if/else statement

based on result of if/else i want to send email (next Task). so assume in a Powershell Task i have sample code as below:

 

$a = 1;

$b = 2;

if ($a -lt $b) {

write-host "Task is successful";

}

else {

write-host "Task failed";

in next Task if it was successful (means entered in if), send email to user and if it failed (means entered in else) send email to admin.

 

Logically script will get executed successfully in any case so it always Trigger the Task (linked with green connector) to send email to user but i want to force it to send email to admin (linked with red connector).

 

i tried Setting ${taskname.POWERSHELL_NATIVE_COMMAND_STATUS} = 0; in else part but this does not help either.

 

any Suggestion?

Everyone's tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Beginner

Re: set a task result based on if/else statement

Hi Kaka,

 

I mean the standard task "If Else" which you can find in the directory "procedural tasks" in the workflow designer. :)

 

Regards,

Jessi

 

 

5 REPLIES 5
Beginner

Re: set a task result based on if/else statement

Hi KAKA_2,

 

is maybe the procendual task "If Else" an option for you?

Normally I'm using this to check a condition ... If the condition true you can using te first connector and send an email to the e.g. user - if the condition false, you can using the second connector to send an email to the administration. And from the email task you can go from the "success" connector to the "failed" task from the workflow to stop them.

 

Or you using a custom task ... I found these example in the UCS Director Cookbook:

Setting a Task to Successful or Failed Status

Objective

Set the Task status to Successful or Failed based on the given condition.

Prerequisites

None

Components

ctxt - Used to set the status message of the workflow task.

Code

if (true) {
	ctxt.setFailed(“Error output message”); // to set the task status as failed 
	ctxt.exit(); // to exit task flow normally
} else {
	ctxt.setSuccessful(); // to set the task status to successful
}

Results

Sets the task status as failed or successful based on the given condition.

Regards,

Jessica

Beginner

Re: set a task result based on if/else statement

Hello Jessica,

 

What do you mean by "procendual Task"? in this particular case i do not want to use custom Task.

 

Thank You.

-KAKA-

 

Beginner

Re: set a task result based on if/else statement

Hi Kaka,

 

I mean the standard task "If Else" which you can find in the directory "procedural tasks" in the workflow designer. :)

 

Regards,

Jessi

 

 

Beginner

Re: set a task result based on if/else statement

Hello Jessi,

 

Thanks. finally i have found it.  with first Impression i see that it look for an condition as Input. in my case, result of Task contains either true or false so i believe i can create a Input variable and set result of prvious Task in this variable which can be later used as test Expression.

 

I will give a try and see if this works.

 

Thanks for your help.

-KAKA-

Beginner

Re: set a task result based on if/else statement

Hello Jessi,

IFElse Task is doing exactly what i was looking for. Thanks for your help.

-KAKA-

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.